[FIX] Indentation

This commit is contained in:
Olivier Ligot
2012-09-12 22:01:13 +02:00
parent f361ce65c6
commit 6cd21c39eb

View File

@@ -1,85 +1,85 @@
note note
description: "A JSON converter for DS_HASH_TABLE [ANY, HASHABLE]" description: "A JSON converter for DS_HASH_TABLE [ANY, HASHABLE]"
author: "Paul Cohen" author: "Paul Cohen"
date: "$Date: $" date: "$Date: $"
revision: "$Revision: $" revision: "$Revision: $"
file: "$HeadURL: $" file: "$HeadURL: $"
class JSON_DS_HASH_TABLE_CONVERTER class JSON_DS_HASH_TABLE_CONVERTER
inherit inherit
JSON_CONVERTER JSON_CONVERTER
create create
make make
feature {NONE} -- Initialization feature {NONE} -- Initialization
make make
do do
create object.make (0) create object.make (0)
end end
feature -- Access feature -- Access
value: JSON_OBJECT value: JSON_OBJECT
object: DS_HASH_TABLE [ANY, HASHABLE] object: DS_HASH_TABLE [ANY, HASHABLE]
feature -- Conversion feature -- Conversion
from_json (j: like value): detachable like object from_json (j: like value): detachable like object
local local
keys: ARRAY [JSON_STRING] keys: ARRAY [JSON_STRING]
i: INTEGER i: INTEGER
h: HASHABLE h: HASHABLE
a: ANY a: ANY
do do
keys := j.current_keys keys := j.current_keys
create Result.make (keys.count) create Result.make (keys.count)
from from
i := 1 i := 1
until until
i > keys.count i > keys.count
loop loop
h ?= json.object (keys [i], void) h ?= json.object (keys [i], void)
check h /= Void end check h /= Void end
a := json.object (j.item (keys [i]), Void) a := json.object (j.item (keys [i]), Void)
Result.put (a, h) Result.put (a, h)
i := i + 1 i := i + 1
end end
end end
to_json (o: like object): like value to_json (o: like object): like value
local local
c: DS_HASH_TABLE_CURSOR [ANY, HASHABLE] c: DS_HASH_TABLE_CURSOR [ANY, HASHABLE]
js: JSON_STRING js: JSON_STRING
jv: JSON_VALUE jv: JSON_VALUE
failed: BOOLEAN failed: BOOLEAN
do do
create Result.make create Result.make
from from
c := o.new_cursor c := o.new_cursor
c.start c.start
until until
c.after c.after
loop loop
if attached {JSON_STRING} json.value (c.key) as l_key then if attached {JSON_STRING} json.value (c.key) as l_key then
js := l_key js := l_key
else else
create js.make_json (c.key.out) create js.make_json (c.key.out)
end end
jv := json.value (c.item) jv := json.value (c.item)
if jv /= Void then if jv /= Void then
Result.put (jv, js) Result.put (jv, js)
else else
failed := True failed := True
end end
c.forth c.forth
end end
if failed then if failed then
Result := Void Result := Void
end end
end end
end -- class JSON_DS_HASH_TABLE_CONVERTER end -- class JSON_DS_HASH_TABLE_CONVERTER