From cb595d27f4fe4ae2a972530b8e471bed2ee3eab6 Mon Sep 17 00:00:00 2001 From: jvelilla Date: Mon, 9 Jun 2008 02:18:34 +0000 Subject: [PATCH] Update JSON_OBJECT, put routine, now follows Eiffel Style based on HAST_TABLE --- json/json.ecf | 43 ++++++++++++++++++++----------------------- json/json_object.e | 16 ++++++++++++---- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/json/json.ecf b/json/json.ecf index 0ffcebc7..9180dcee 100644 --- a/json/json.ecf +++ b/json/json.ecf @@ -1,23 +1,20 @@ - - - - - - - - - /EIFGENs$ - /.svn$ - /CVS$ - - - ^/scanner$ - - - - - - - - + + + + + + + + + /EIFGENs$ + /.svn$ + /CVS$ + + + ^/scanner$ + + + + + diff --git a/json/json_object.e b/json/json_object.e index 0718ab9e..a5faa59f 100644 --- a/json/json_object.e +++ b/json/json_object.e @@ -36,10 +36,11 @@ feature -- Initialization feature -- Change Element - put(key:JSON_STRING; value:JSON_VALUE) is - -- + put(value:JSON_VALUE ; key:JSON_STRING) is + -- Assuming there is no item of key `key', + -- insert `value' with `key'. require - not_null: key /= Void + not_present: not has_key (key) local l_json_null:JSON_NULL l_value:JSON_VALUE @@ -52,6 +53,7 @@ feature -- Change Element object.extend(l_value,key) end + feature -- Access has_key(key:JSON_STRING):BOOLEAN is -- has the JSON_OBJECT contains a specific key 'key'. @@ -59,13 +61,19 @@ feature -- Access Result := object.has (key) end + has_item(value:JSON_VALUE):BOOLEAN is + -- has the JSON_OBJECT contain a specfic item 'value' + do + Result := object.has_item (value) + 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 + current_keys:ARRAY[JSON_STRING] is -- array containing actually used keys do Result:=object.current_keys