This commit is contained in:
Jocelyn Fiat
2012-06-29 10:36:53 +02:00

View File

@@ -22,6 +22,8 @@ class
inherit
JSON_VALUE
TABLE_ITERABLE [JSON_VALUE, JSON_STRING]
create
make
@@ -41,7 +43,7 @@ feature -- Change Element
require
key_not_present: not has_key (key)
local
l_value: detachable JSON_VALUE
l_value: like value
do
l_value := value
if l_value = Void then
@@ -50,6 +52,19 @@ feature -- Change Element
object.extend (l_value, key)
end
replace (value: detachable JSON_VALUE; key: JSON_STRING)
-- Assuming there is no item of key `key',
-- insert `value' with `key'.
local
l_value: like value
do
l_value := value
if l_value = Void then
create {JSON_NULL} l_value
end
object.force (l_value, key)
end
feature -- Access
has_key (key: JSON_STRING): BOOLEAN
@@ -98,6 +113,22 @@ feature -- Access
Result.append_character ('}')
end
feature -- Mesurement
count: INTEGER
-- Number of field
do
Result := object.count
end
feature -- Access
new_cursor: TABLE_ITERATION_CURSOR [JSON_VALUE, JSON_STRING]
-- Fresh cursor associated with current structure
do
Result := object.new_cursor
end
feature -- Status report
is_empty: BOOLEAN