Update JSON_STRING rutine is_equal
Update JSON_OBJECT new features (has_keys, item,get_keys), and fixed an incorrect use of HASH_TABLE
This commit is contained in:
@@ -38,6 +38,8 @@ feature -- Change Element
|
||||
|
||||
put(key:JSON_STRING; value:JSON_VALUE) is
|
||||
--
|
||||
require
|
||||
not_null: key /= Void
|
||||
local
|
||||
l_json_null:JSON_NULL
|
||||
l_value:JSON_VALUE
|
||||
@@ -47,9 +49,30 @@ feature -- Change Element
|
||||
create l_json_null
|
||||
l_value:=l_json_null
|
||||
end
|
||||
object.extend(key, l_value)
|
||||
object.extend(l_value,key)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
has_key(key:JSON_STRING):BOOLEAN is
|
||||
-- has the JSON_OBJECT contains a specific key 'key'.
|
||||
do
|
||||
Result := object.has (key)
|
||||
end
|
||||
|
||||
item(key:JSON_STRING):JSON_VALUE is
|
||||
-- the json_value associated with a key.
|
||||
do
|
||||
Result:= object.item (key)
|
||||
end
|
||||
|
||||
get_keys:ARRAY[JSON_STRING] is
|
||||
--
|
||||
do
|
||||
Result:=object.current_keys
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
feature -- Report
|
||||
to_json:STRING is
|
||||
@@ -95,6 +118,6 @@ feature -- Report
|
||||
end
|
||||
|
||||
|
||||
feature -- Implementation
|
||||
object:HASH_TABLE[JSON_STRING,JSON_VALUE]
|
||||
feature {NONE} -- Implementation
|
||||
object:HASH_TABLE[JSON_VALUE,JSON_STRING]
|
||||
end
|
||||
|
||||
@@ -14,8 +14,8 @@ class
|
||||
JSON_STRING
|
||||
inherit
|
||||
JSON_VALUE
|
||||
rename
|
||||
is_equal as is_equal_json
|
||||
redefine
|
||||
is_equal
|
||||
end
|
||||
|
||||
create
|
||||
@@ -30,6 +30,13 @@ feature -- Initialization
|
||||
|
||||
|
||||
feature -- Access
|
||||
feature -- Comparison
|
||||
is_equal (other: like Current): BOOLEAN is
|
||||
-- Is JSON_STRING made of same character sequence as `other'
|
||||
-- (possibly with a different capacity)?
|
||||
do
|
||||
Result:= Current.to_json.is_equal (other.to_json)
|
||||
end
|
||||
|
||||
feature -- Change Element
|
||||
append(value:STRING)is
|
||||
@@ -57,7 +64,4 @@ feature -- Status report
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
buffer:STRING
|
||||
invariant
|
||||
invariant_clause: True -- Your invariant here
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user