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
|
put(key:JSON_STRING; value:JSON_VALUE) is
|
||||||
--
|
--
|
||||||
|
require
|
||||||
|
not_null: key /= Void
|
||||||
local
|
local
|
||||||
l_json_null:JSON_NULL
|
l_json_null:JSON_NULL
|
||||||
l_value:JSON_VALUE
|
l_value:JSON_VALUE
|
||||||
@@ -47,9 +49,30 @@ feature -- Change Element
|
|||||||
create l_json_null
|
create l_json_null
|
||||||
l_value:=l_json_null
|
l_value:=l_json_null
|
||||||
end
|
end
|
||||||
object.extend(key, l_value)
|
object.extend(l_value,key)
|
||||||
end
|
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
|
feature -- Report
|
||||||
to_json:STRING is
|
to_json:STRING is
|
||||||
@@ -95,6 +118,6 @@ feature -- Report
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
feature -- Implementation
|
feature {NONE} -- Implementation
|
||||||
object:HASH_TABLE[JSON_STRING,JSON_VALUE]
|
object:HASH_TABLE[JSON_VALUE,JSON_STRING]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ class
|
|||||||
JSON_STRING
|
JSON_STRING
|
||||||
inherit
|
inherit
|
||||||
JSON_VALUE
|
JSON_VALUE
|
||||||
rename
|
redefine
|
||||||
is_equal as is_equal_json
|
is_equal
|
||||||
end
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
@@ -30,6 +30,13 @@ feature -- Initialization
|
|||||||
|
|
||||||
|
|
||||||
feature -- Access
|
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
|
feature -- Change Element
|
||||||
append(value:STRING)is
|
append(value:STRING)is
|
||||||
@@ -57,7 +64,4 @@ feature -- Status report
|
|||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
buffer:STRING
|
buffer:STRING
|
||||||
invariant
|
|
||||||
invariant_clause: True -- Your invariant here
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user