@@ -26,7 +26,9 @@ feature -- Access
|
|||||||
create template_content.make_empty
|
create template_content.make_empty
|
||||||
l_file.read_stream (l_file.count)
|
l_file.read_stream (l_file.count)
|
||||||
l_last_string := l_file.last_string
|
l_last_string := l_file.last_string
|
||||||
check l_last_string /= Void end -- implied by postcondition of `l_file.read_stream'
|
check
|
||||||
|
l_last_string /= Void
|
||||||
|
end -- implied by postcondition of `l_file.read_stream'
|
||||||
template_content.append (l_last_string.string)
|
template_content.append (l_last_string.string)
|
||||||
Result := template_content
|
Result := template_content
|
||||||
l_file.close
|
l_file.close
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
note
|
note
|
||||||
description:
|
description: "JSON Iterator"
|
||||||
|
|
||||||
"JSON Iterator"
|
|
||||||
|
|
||||||
pattern: "Iterator visitor"
|
pattern: "Iterator visitor"
|
||||||
author: "Jocelyn Fiat"
|
author: "Jocelyn Fiat"
|
||||||
license:"MIT (see http://www.opensource.org/licenses/mit-license.php)"
|
license: "MIT (see http://www.opensource.org/licenses/mit-license.php)"
|
||||||
date: "2013/08/01"
|
date: "2013/08/01"
|
||||||
revision: "Revision 0.1"
|
revision: "Revision 0.1"
|
||||||
|
|
||||||
@@ -13,6 +10,7 @@ deferred class
|
|||||||
JSON_ITERATOR
|
JSON_ITERATOR
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_VISITOR
|
JSON_VISITOR
|
||||||
|
|
||||||
feature -- Visitor Pattern
|
feature -- Visitor Pattern
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ class
|
|||||||
JSON_PRETTY_STRING_VISITOR
|
JSON_PRETTY_STRING_VISITOR
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_VISITOR
|
JSON_VISITOR
|
||||||
|
|
||||||
create
|
create
|
||||||
make,
|
make, make_custom
|
||||||
make_custom
|
|
||||||
|
|
||||||
feature -- Initialization
|
feature -- Initialization
|
||||||
|
|
||||||
@@ -26,7 +26,6 @@ feature -- Initialization
|
|||||||
output := a_output
|
output := a_output
|
||||||
create indentation.make_empty
|
create indentation.make_empty
|
||||||
indentation_step := "%T"
|
indentation_step := "%T"
|
||||||
|
|
||||||
object_count_inlining := a_object_count_inlining
|
object_count_inlining := a_object_count_inlining
|
||||||
array_count_inlining := a_array_count_inlining
|
array_count_inlining := a_array_count_inlining
|
||||||
end
|
end
|
||||||
@@ -60,6 +59,7 @@ feature -- Access
|
|||||||
end
|
end
|
||||||
|
|
||||||
object_count_inlining: INTEGER
|
object_count_inlining: INTEGER
|
||||||
|
|
||||||
array_count_inlining: INTEGER
|
array_count_inlining: INTEGER
|
||||||
|
|
||||||
feature -- Visitor Pattern
|
feature -- Visitor Pattern
|
||||||
@@ -82,10 +82,7 @@ feature -- Visitor Pattern
|
|||||||
until
|
until
|
||||||
l_json_array.off
|
l_json_array.off
|
||||||
loop
|
loop
|
||||||
if
|
if line_number > l_line or l_multiple_lines then
|
||||||
line_number > l_line or
|
|
||||||
l_multiple_lines
|
|
||||||
then
|
|
||||||
new_line
|
new_line
|
||||||
end
|
end
|
||||||
value := l_json_array.item
|
value := l_json_array.item
|
||||||
@@ -96,10 +93,7 @@ feature -- Visitor Pattern
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
exdent
|
exdent
|
||||||
if
|
if line_number > l_line or l_json_array.count >= array_count_inlining then
|
||||||
line_number > l_line or
|
|
||||||
l_json_array.count >= array_count_inlining
|
|
||||||
then
|
|
||||||
new_line
|
new_line
|
||||||
end
|
end
|
||||||
output.append ("]")
|
output.append ("]")
|
||||||
@@ -140,10 +134,7 @@ feature -- Visitor Pattern
|
|||||||
until
|
until
|
||||||
l_pairs.off
|
l_pairs.off
|
||||||
loop
|
loop
|
||||||
if
|
if line_number > l_line or l_multiple_lines then
|
||||||
line_number > l_line or
|
|
||||||
l_multiple_lines
|
|
||||||
then
|
|
||||||
new_line
|
new_line
|
||||||
end
|
end
|
||||||
l_pairs.key_for_iteration.accept (Current)
|
l_pairs.key_for_iteration.accept (Current)
|
||||||
@@ -155,10 +146,7 @@ feature -- Visitor Pattern
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
exdent
|
exdent
|
||||||
if
|
if line_number > l_line or l_pairs.count >= object_count_inlining then
|
||||||
line_number > l_line or
|
|
||||||
l_pairs.count >= object_count_inlining
|
|
||||||
then
|
|
||||||
new_line
|
new_line
|
||||||
end
|
end
|
||||||
output.append ("}")
|
output.append ("}")
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
note
|
note
|
||||||
description:
|
description: "JSON Visitor"
|
||||||
|
|
||||||
"JSON Visitor"
|
|
||||||
|
|
||||||
pattern: "Visitor"
|
pattern: "Visitor"
|
||||||
author: "Javier Velilla"
|
author: "Javier Velilla"
|
||||||
license:"MIT (see http://www.opensource.org/licenses/mit-license.php)"
|
license: "MIT (see http://www.opensource.org/licenses/mit-license.php)"
|
||||||
date: "2008/08/24"
|
date: "2008/08/24"
|
||||||
revision: "Revision 0.1"
|
revision: "Revision 0.1"
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ class
|
|||||||
PRINT_JSON_VISITOR
|
PRINT_JSON_VISITOR
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_VISITOR
|
JSON_VISITOR
|
||||||
|
|
||||||
create make
|
create
|
||||||
|
make
|
||||||
|
|
||||||
feature -- Initialization
|
feature -- Initialization
|
||||||
|
|
||||||
@@ -33,7 +35,7 @@ feature -- Visitor Pattern
|
|||||||
value: JSON_VALUE
|
value: JSON_VALUE
|
||||||
l_json_array: ARRAYED_LIST [JSON_VALUE]
|
l_json_array: ARRAYED_LIST [JSON_VALUE]
|
||||||
do
|
do
|
||||||
l_json_array:=a_json_array.array_representation
|
l_json_array := a_json_array.array_representation
|
||||||
to_json.append ("[")
|
to_json.append ("[")
|
||||||
from
|
from
|
||||||
l_json_array.start
|
l_json_array.start
|
||||||
@@ -44,7 +46,7 @@ feature -- Visitor Pattern
|
|||||||
value.accept (Current)
|
value.accept (Current)
|
||||||
l_json_array.forth
|
l_json_array.forth
|
||||||
if not l_json_array.after then
|
if not l_json_array.after then
|
||||||
to_json.append(",")
|
to_json.append (",")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
to_json.append ("]")
|
to_json.append ("]")
|
||||||
@@ -71,7 +73,7 @@ feature -- Visitor Pattern
|
|||||||
visit_json_object (a_json_object: JSON_OBJECT)
|
visit_json_object (a_json_object: JSON_OBJECT)
|
||||||
-- Visit `a_json_object'.
|
-- Visit `a_json_object'.
|
||||||
local
|
local
|
||||||
l_pairs: HASH_TABLE[JSON_VALUE,JSON_STRING]
|
l_pairs: HASH_TABLE [JSON_VALUE, JSON_STRING]
|
||||||
do
|
do
|
||||||
l_pairs := a_json_object.map_representation
|
l_pairs := a_json_object.map_representation
|
||||||
to_json.append ("{")
|
to_json.append ("{")
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ note
|
|||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
file: "$HeadURL: $"
|
file: "$HeadURL: $"
|
||||||
|
|
||||||
class JSON_ARRAYED_LIST_CONVERTER
|
class
|
||||||
|
JSON_ARRAYED_LIST_CONVERTER
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_LIST_CONVERTER
|
JSON_LIST_CONVERTER
|
||||||
redefine
|
redefine
|
||||||
object
|
object
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ note
|
|||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
file: "$HeadURL: $"
|
file: "$HeadURL: $"
|
||||||
|
|
||||||
deferred class JSON_CONVERTER
|
deferred class
|
||||||
|
JSON_CONVERTER
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
SHARED_EJSON
|
SHARED_EJSON
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ note
|
|||||||
revision: "$Revision: 94128 $"
|
revision: "$Revision: 94128 $"
|
||||||
file: "$HeadURL: $"
|
file: "$HeadURL: $"
|
||||||
|
|
||||||
class JSON_HASH_TABLE_CONVERTER
|
class
|
||||||
|
JSON_HASH_TABLE_CONVERTER
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_CONVERTER
|
JSON_CONVERTER
|
||||||
|
|
||||||
create
|
create
|
||||||
@@ -36,10 +38,14 @@ feature -- Conversion
|
|||||||
if attached {HASHABLE} json.object (ic.key, Void) as h then
|
if attached {HASHABLE} json.object (ic.key, Void) as h then
|
||||||
Result.put (l_object, h)
|
Result.put (l_object, h)
|
||||||
else
|
else
|
||||||
check key_is_hashable: False end
|
check
|
||||||
|
key_is_hashable: False
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
check object_attached: False end
|
check
|
||||||
|
object_attached: False
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ note
|
|||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
file: "$HeadURL: $"
|
file: "$HeadURL: $"
|
||||||
|
|
||||||
class JSON_LINKED_LIST_CONVERTER
|
class
|
||||||
|
JSON_LINKED_LIST_CONVERTER
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_LIST_CONVERTER
|
JSON_LIST_CONVERTER
|
||||||
redefine
|
redefine
|
||||||
object
|
object
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ note
|
|||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
file: "$HeadURL: $"
|
file: "$HeadURL: $"
|
||||||
|
|
||||||
deferred class JSON_LIST_CONVERTER
|
deferred class
|
||||||
|
JSON_LIST_CONVERTER
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_CONVERTER
|
JSON_CONVERTER
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ note
|
|||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
file: "$HeadURL: $"
|
file: "$HeadURL: $"
|
||||||
|
|
||||||
class EJSON
|
class
|
||||||
|
EJSON
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
EXCEPTIONS
|
EXCEPTIONS
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
@@ -56,7 +58,9 @@ feature -- Access
|
|||||||
if attached value (a @ i) as v then
|
if attached value (a @ i) as v then
|
||||||
ja.add (v)
|
ja.add (v)
|
||||||
else
|
else
|
||||||
check value_attached: False end
|
check
|
||||||
|
value_attached: False
|
||||||
|
end
|
||||||
end
|
end
|
||||||
i := i + 1
|
i := i + 1
|
||||||
end
|
end
|
||||||
@@ -65,13 +69,11 @@ feature -- Access
|
|||||||
create {JSON_STRING} Result.make_json (c8.out)
|
create {JSON_STRING} Result.make_json (c8.out)
|
||||||
elseif attached {CHARACTER_32} an_object as c32 then
|
elseif attached {CHARACTER_32} an_object as c32 then
|
||||||
create {JSON_STRING} Result.make_json (c32.out)
|
create {JSON_STRING} Result.make_json (c32.out)
|
||||||
|
|
||||||
elseif attached {STRING_8} an_object as s8 then
|
elseif attached {STRING_8} an_object as s8 then
|
||||||
create {JSON_STRING} Result.make_json (s8)
|
create {JSON_STRING} Result.make_json (s8)
|
||||||
elseif attached {STRING_32} an_object as s32 then
|
elseif attached {STRING_32} an_object as s32 then
|
||||||
create {JSON_STRING} Result.make_json_from_string_32 (s32)
|
create {JSON_STRING} Result.make_json_from_string_32 (s32)
|
||||||
end
|
end
|
||||||
|
|
||||||
if Result = Void then
|
if Result = Void then
|
||||||
-- Now check the converters
|
-- Now check the converters
|
||||||
if an_object /= Void and then attached converter_for (an_object) as jc then
|
if an_object /= Void and then attached converter_for (an_object) as jc then
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ note
|
|||||||
[]
|
[]
|
||||||
[elements]
|
[elements]
|
||||||
]"
|
]"
|
||||||
|
|
||||||
author: "Javier Velilla"
|
author: "Javier Velilla"
|
||||||
date: "2008/08/24"
|
date: "2008/08/24"
|
||||||
revision: "Revision 0.1"
|
revision: "Revision 0.1"
|
||||||
@@ -16,6 +15,7 @@ class
|
|||||||
JSON_ARRAY
|
JSON_ARRAY
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_VALUE
|
JSON_VALUE
|
||||||
|
|
||||||
ITERABLE [JSON_VALUE]
|
ITERABLE [JSON_VALUE]
|
||||||
@@ -103,8 +103,7 @@ feature -- Change Element
|
|||||||
do
|
do
|
||||||
values.put_front (v)
|
values.put_front (v)
|
||||||
ensure
|
ensure
|
||||||
has_new_value: old values.count + 1 = values.count and
|
has_new_value: old values.count + 1 = values.count and values.first = v
|
||||||
values.first = v
|
|
||||||
end
|
end
|
||||||
|
|
||||||
add, extend (v: JSON_VALUE)
|
add, extend (v: JSON_VALUE)
|
||||||
@@ -113,8 +112,7 @@ feature -- Change Element
|
|||||||
do
|
do
|
||||||
values.extend (v)
|
values.extend (v)
|
||||||
ensure
|
ensure
|
||||||
has_new_value: old values.count + 1 = values.count and
|
has_new_value: old values.count + 1 = values.count and values.has (v)
|
||||||
values.has (v)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
prune_all (v: JSON_VALUE)
|
prune_all (v: JSON_VALUE)
|
||||||
@@ -144,7 +142,7 @@ feature -- Report
|
|||||||
until
|
until
|
||||||
values.off
|
values.off
|
||||||
loop
|
loop
|
||||||
Result:= ((Result \\ 8388593) |<< 8) + values.item.hash_code
|
Result := ((Result \\ 8388593) |<< 8) + values.item.hash_code
|
||||||
values.forth
|
values.forth
|
||||||
end
|
end
|
||||||
Result := Result \\ values.count
|
Result := Result \\ values.count
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class
|
|||||||
JSON_BOOLEAN
|
JSON_BOOLEAN
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_VALUE
|
JSON_VALUE
|
||||||
|
|
||||||
create
|
create
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class
|
|||||||
JSON_NULL
|
JSON_NULL
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_VALUE
|
JSON_VALUE
|
||||||
|
|
||||||
feature --Access
|
feature --Access
|
||||||
@@ -40,7 +41,7 @@ feature -- Status report
|
|||||||
Result := null_value
|
Result := null_value
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {NONE}-- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
null_value: STRING = "null"
|
null_value: STRING = "null"
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,22 @@
|
|||||||
note
|
note
|
||||||
|
|
||||||
description: "JSON Numbers, octal and hexadecimal formats are not used."
|
description: "JSON Numbers, octal and hexadecimal formats are not used."
|
||||||
author: "Javier Velilla"
|
author: "Javier Velilla"
|
||||||
date: "2008/08/24"
|
date: "2008/08/24"
|
||||||
revision: "Revision 0.1"
|
revision: "Revision 0.1"
|
||||||
license:"MIT (see http://www.opensource.org/licenses/mit-license.php)"
|
license: "MIT (see http://www.opensource.org/licenses/mit-license.php)"
|
||||||
|
|
||||||
class
|
class
|
||||||
JSON_NUMBER
|
JSON_NUMBER
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_VALUE
|
JSON_VALUE
|
||||||
redefine
|
redefine
|
||||||
is_equal
|
is_equal
|
||||||
end
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
make_integer,
|
make_integer, make_natural, make_real
|
||||||
make_natural,
|
|
||||||
make_real
|
|
||||||
|
|
||||||
feature {NONE} -- initialization
|
feature {NONE} -- initialization
|
||||||
|
|
||||||
@@ -88,7 +86,9 @@ feature -- Status report
|
|||||||
feature -- Implementation
|
feature -- Implementation
|
||||||
|
|
||||||
INTEGER_TYPE: INTEGER = 1
|
INTEGER_TYPE: INTEGER = 1
|
||||||
|
|
||||||
DOUBLE_TYPE: INTEGER = 2
|
DOUBLE_TYPE: INTEGER = 2
|
||||||
|
|
||||||
NATURAL_TYPE: INTEGER = 3
|
NATURAL_TYPE: INTEGER = 3
|
||||||
|
|
||||||
numeric_type: INTEGER
|
numeric_type: INTEGER
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
note
|
note
|
||||||
|
|
||||||
description: "[
|
description: "[
|
||||||
An JSON_OBJECT represent an object in JSON.
|
An JSON_OBJECT represent an object in JSON.
|
||||||
An object is an unordered set of name/value pairs
|
An object is an unordered set of name/value pairs
|
||||||
@@ -9,17 +8,17 @@ note
|
|||||||
object
|
object
|
||||||
{}
|
{}
|
||||||
{"key": "value"}
|
{"key": "value"}
|
||||||
|
|
||||||
]"
|
]"
|
||||||
author: "Javier Velilla"
|
author: "Javier Velilla"
|
||||||
date: "2008/08/24"
|
date: "2008/08/24"
|
||||||
revision: "Revision 0.1"
|
revision: "Revision 0.1"
|
||||||
license:"MIT (see http://www.opensource.org/licenses/mit-license.php)"
|
license: "MIT (see http://www.opensource.org/licenses/mit-license.php)"
|
||||||
|
|
||||||
class
|
class
|
||||||
JSON_OBJECT
|
JSON_OBJECT
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_VALUE
|
JSON_VALUE
|
||||||
|
|
||||||
TABLE_ITERABLE [JSON_VALUE, JSON_STRING]
|
TABLE_ITERABLE [JSON_VALUE, JSON_STRING]
|
||||||
@@ -66,7 +65,6 @@ feature -- Change Element
|
|||||||
put (l_value, key)
|
put (l_value, key)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
put_integer (value: INTEGER_64; key: JSON_STRING)
|
put_integer (value: INTEGER_64; key: JSON_STRING)
|
||||||
-- Assuming there is no item of key `key',
|
-- Assuming there is no item of key `key',
|
||||||
-- insert `value' with `key'.
|
-- insert `value' with `key'.
|
||||||
|
|||||||
@@ -1,30 +1,26 @@
|
|||||||
note
|
note
|
||||||
|
|
||||||
description: "[
|
description: "[
|
||||||
A JSON_STRING represent a string in JSON.
|
A JSON_STRING represent a string in JSON.
|
||||||
A string is a collection of zero or more Unicodes characters, wrapped in double
|
A string is a collection of zero or more Unicodes characters, wrapped in double
|
||||||
quotes, using blackslash espaces.
|
quotes, using blackslash espaces.
|
||||||
]"
|
]"
|
||||||
|
|
||||||
author: "Javier Velilla"
|
author: "Javier Velilla"
|
||||||
date: "2008/08/24"
|
date: "2008/08/24"
|
||||||
revision: "Revision 0.1"
|
revision: "Revision 0.1"
|
||||||
license:"MIT (see http://www.opensource.org/licenses/mit-license.php)"
|
license: "MIT (see http://www.opensource.org/licenses/mit-license.php)"
|
||||||
|
|
||||||
|
|
||||||
class
|
class
|
||||||
JSON_STRING
|
JSON_STRING
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_VALUE
|
JSON_VALUE
|
||||||
redefine
|
redefine
|
||||||
is_equal
|
is_equal
|
||||||
end
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
make_json,
|
make_json, make_json_from_string_32, make_with_escaped_json
|
||||||
make_json_from_string_32,
|
|
||||||
make_with_escaped_json
|
|
||||||
|
|
||||||
convert
|
convert
|
||||||
make_json ({READABLE_STRING_8, STRING_8, IMMUTABLE_STRING_8}),
|
make_json ({READABLE_STRING_8, STRING_8, IMMUTABLE_STRING_8}),
|
||||||
@@ -105,11 +101,15 @@ feature -- Conversion
|
|||||||
do
|
do
|
||||||
s := item
|
s := item
|
||||||
n := s.count
|
n := s.count
|
||||||
from i := 1 until i > n loop
|
from
|
||||||
c := s[i]
|
i := 1
|
||||||
|
until
|
||||||
|
i > n
|
||||||
|
loop
|
||||||
|
c := s [i]
|
||||||
if c = '\' then
|
if c = '\' then
|
||||||
if i < n then
|
if i < n then
|
||||||
inspect s[i+1]
|
inspect s [i + 1]
|
||||||
when '\' then
|
when '\' then
|
||||||
a_output.append_character ('\')
|
a_output.append_character ('\')
|
||||||
i := i + 2
|
i := i + 2
|
||||||
@@ -163,11 +163,15 @@ feature -- Conversion
|
|||||||
do
|
do
|
||||||
s := item
|
s := item
|
||||||
n := s.count
|
n := s.count
|
||||||
from i := 1 until i > n loop
|
from
|
||||||
|
i := 1
|
||||||
|
until
|
||||||
|
i > n
|
||||||
|
loop
|
||||||
ch := s.item (i)
|
ch := s.item (i)
|
||||||
if ch = '\' then
|
if ch = '\' then
|
||||||
if i < n then
|
if i < n then
|
||||||
inspect s[i+1]
|
inspect s [i + 1]
|
||||||
when '\' then
|
when '\' then
|
||||||
a_output.append_character ('\')
|
a_output.append_character ('\')
|
||||||
i := i + 2
|
i := i + 2
|
||||||
@@ -207,37 +211,27 @@ feature -- Conversion
|
|||||||
c := ch.natural_32_code
|
c := ch.natural_32_code
|
||||||
if c <= 0x7F then
|
if c <= 0x7F then
|
||||||
-- 0xxxxxxx
|
-- 0xxxxxxx
|
||||||
check ch = c.to_character_32 end
|
check
|
||||||
|
ch = c.to_character_32
|
||||||
|
end
|
||||||
a_output.append_character (ch)
|
a_output.append_character (ch)
|
||||||
elseif c <= 0xDF then
|
elseif c <= 0xDF then
|
||||||
-- 110xxxxx 10xxxxxx
|
-- 110xxxxx 10xxxxxx
|
||||||
i := i + 1
|
i := i + 1
|
||||||
if i <= n then
|
if i <= n then
|
||||||
a_output.append_code (
|
a_output.append_code (((c & 0x1F) |<< 6) | (s.code (i) & 0x3F))
|
||||||
((c & 0x1F) |<< 6) |
|
|
||||||
(s.code (i) & 0x3F)
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
elseif c <= 0xEF then
|
elseif c <= 0xEF then
|
||||||
-- 1110xxxx 10xxxxxx 10xxxxxx
|
-- 1110xxxx 10xxxxxx 10xxxxxx
|
||||||
i := i + 2
|
i := i + 2
|
||||||
if i <= n then
|
if i <= n then
|
||||||
a_output.append_code (
|
a_output.append_code (((c & 0xF) |<< 12) | ((s.code (i - 1) & 0x3F) |<< 6) | (s.code (i) & 0x3F))
|
||||||
((c & 0xF) |<< 12) |
|
|
||||||
((s.code (i - 1) & 0x3F) |<< 6) |
|
|
||||||
(s.code (i) & 0x3F)
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
elseif c <= 0xF7 then
|
elseif c <= 0xF7 then
|
||||||
-- 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
-- 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||||
i := i + 3
|
i := i + 3
|
||||||
if i <= n then
|
if i <= n then
|
||||||
a_output.append_code (
|
a_output.append_code (((c & 0x7) |<< 18) | ((s.code (i - 2) & 0x3F) |<< 12) | ((s.code (i - 1) & 0x3F) |<< 6) | (s.code (i) & 0x3F))
|
||||||
((c & 0x7) |<< 18) |
|
|
||||||
((s.code (i - 2) & 0x3F) |<< 12) |
|
|
||||||
((s.code (i - 1) & 0x3F) |<< 6) |
|
|
||||||
(s.code (i) & 0x3F)
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
i := i + 1
|
i := i + 1
|
||||||
@@ -302,7 +296,7 @@ feature {NONE} -- Implementation
|
|||||||
until
|
until
|
||||||
i > s.count or not Result
|
i > s.count or not Result
|
||||||
loop
|
loop
|
||||||
Result := s[i].is_hexa_digit
|
Result := s [i].is_hexa_digit
|
||||||
i := i + 1
|
i := i + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -317,13 +311,11 @@ feature {NONE} -- Implementation
|
|||||||
char: CHARACTER
|
char: CHARACTER
|
||||||
do
|
do
|
||||||
nb := s.count
|
nb := s.count
|
||||||
|
|
||||||
if nb >= 2 and then s.item (2) = 'x' then
|
if nb >= 2 and then s.item (2) = 'x' then
|
||||||
i := 3
|
i := 3
|
||||||
else
|
else
|
||||||
i := 1
|
i := 1
|
||||||
end
|
end
|
||||||
|
|
||||||
from
|
from
|
||||||
until
|
until
|
||||||
i > nb
|
i > nb
|
||||||
@@ -349,16 +341,27 @@ feature {NONE} -- Implementation
|
|||||||
do
|
do
|
||||||
n := s.count
|
n := s.count
|
||||||
create Result.make (n + n // 10)
|
create Result.make (n + n // 10)
|
||||||
from i := 1 until i > n loop
|
from
|
||||||
|
i := 1
|
||||||
|
until
|
||||||
|
i > n
|
||||||
|
loop
|
||||||
c := s.item (i)
|
c := s.item (i)
|
||||||
inspect c
|
inspect c
|
||||||
when '%"' then Result.append_string ("\%"")
|
when '%"' then
|
||||||
when '\' then Result.append_string ("\\")
|
Result.append_string ("\%"")
|
||||||
when '%B' then Result.append_string ("\b")
|
when '\' then
|
||||||
when '%F' then Result.append_string ("\f")
|
Result.append_string ("\\")
|
||||||
when '%N' then Result.append_string ("\n")
|
when '%B' then
|
||||||
when '%R' then Result.append_string ("\r")
|
Result.append_string ("\b")
|
||||||
when '%T' then Result.append_string ("\t")
|
when '%F' then
|
||||||
|
Result.append_string ("\f")
|
||||||
|
when '%N' then
|
||||||
|
Result.append_string ("\n")
|
||||||
|
when '%R' then
|
||||||
|
Result.append_string ("\r")
|
||||||
|
when '%T' then
|
||||||
|
Result.append_string ("\t")
|
||||||
else
|
else
|
||||||
Result.extend (c)
|
Result.extend (c)
|
||||||
end
|
end
|
||||||
@@ -378,18 +381,29 @@ feature {NONE} -- Implementation
|
|||||||
do
|
do
|
||||||
n := s.count
|
n := s.count
|
||||||
create Result.make (n + n // 10)
|
create Result.make (n + n // 10)
|
||||||
from i := 1 until i > n loop
|
from
|
||||||
|
i := 1
|
||||||
|
until
|
||||||
|
i > n
|
||||||
|
loop
|
||||||
uc := s.item (i)
|
uc := s.item (i)
|
||||||
if uc.is_character_8 then
|
if uc.is_character_8 then
|
||||||
c := uc.to_character_8
|
c := uc.to_character_8
|
||||||
inspect c
|
inspect c
|
||||||
when '%"' then Result.append_string ("\%"")
|
when '%"' then
|
||||||
when '\' then Result.append_string ("\\")
|
Result.append_string ("\%"")
|
||||||
when '%B' then Result.append_string ("\b")
|
when '\' then
|
||||||
when '%F' then Result.append_string ("\f")
|
Result.append_string ("\\")
|
||||||
when '%N' then Result.append_string ("\n")
|
when '%B' then
|
||||||
when '%R' then Result.append_string ("\r")
|
Result.append_string ("\b")
|
||||||
when '%T' then Result.append_string ("\t")
|
when '%F' then
|
||||||
|
Result.append_string ("\f")
|
||||||
|
when '%N' then
|
||||||
|
Result.append_string ("\n")
|
||||||
|
when '%R' then
|
||||||
|
Result.append_string ("\r")
|
||||||
|
when '%T' then
|
||||||
|
Result.append_string ("\t")
|
||||||
else
|
else
|
||||||
Result.extend (c)
|
Result.extend (c)
|
||||||
end
|
end
|
||||||
@@ -405,14 +419,15 @@ feature {NONE} -- Implementation
|
|||||||
j := j + 1
|
j := j + 1
|
||||||
end
|
end
|
||||||
h := h.substring (j, h.count)
|
h := h.substring (j, h.count)
|
||||||
|
|
||||||
from
|
from
|
||||||
until
|
until
|
||||||
h.count >= 4
|
h.count >= 4
|
||||||
loop
|
loop
|
||||||
h.prepend_integer (0)
|
h.prepend_integer (0)
|
||||||
end
|
end
|
||||||
check h.count = 4 end
|
check
|
||||||
|
h.count = 4
|
||||||
|
end
|
||||||
Result.append (h)
|
Result.append (h)
|
||||||
end
|
end
|
||||||
i := i + 1
|
i := i + 1
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
note
|
note
|
||||||
description:"[
|
description: "[
|
||||||
JSON_VALUE represent a value in JSON.
|
JSON_VALUE represent a value in JSON.
|
||||||
A value can be
|
A value can be
|
||||||
* a string in double quotes
|
* a string in double quotes
|
||||||
@@ -12,13 +12,13 @@ note
|
|||||||
author: "Javier Velilla"
|
author: "Javier Velilla"
|
||||||
date: "2008/05/19"
|
date: "2008/05/19"
|
||||||
revision: "Revision 0.1"
|
revision: "Revision 0.1"
|
||||||
license:"MIT (see http://www.opensource.org/licenses/mit-license.php)"
|
license: "MIT (see http://www.opensource.org/licenses/mit-license.php)"
|
||||||
|
|
||||||
|
|
||||||
deferred class
|
deferred class
|
||||||
JSON_VALUE
|
JSON_VALUE
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
HASHABLE
|
HASHABLE
|
||||||
|
|
||||||
DEBUG_OUTPUT
|
DEBUG_OUTPUT
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
note
|
note
|
||||||
|
|
||||||
description: "Parse serialized JSON data"
|
description: "Parse serialized JSON data"
|
||||||
author: "jvelilla"
|
author: "jvelilla"
|
||||||
date: "2008/08/24"
|
date: "2008/08/24"
|
||||||
@@ -9,7 +8,9 @@ class
|
|||||||
JSON_PARSER
|
JSON_PARSER
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_READER
|
JSON_READER
|
||||||
|
|
||||||
JSON_TOKENS
|
JSON_TOKENS
|
||||||
|
|
||||||
create
|
create
|
||||||
@@ -139,7 +140,11 @@ feature -- Commands
|
|||||||
else
|
else
|
||||||
-- a complex object {"key" : "value"}
|
-- a complex object {"key" : "value"}
|
||||||
previous
|
previous
|
||||||
from has_more := True until not has_more loop
|
from
|
||||||
|
has_more := True
|
||||||
|
until
|
||||||
|
not has_more
|
||||||
|
loop
|
||||||
next
|
next
|
||||||
skip_white_spaces
|
skip_white_spaces
|
||||||
l_json_string := parse_string
|
l_json_string := parse_string
|
||||||
@@ -153,7 +158,6 @@ feature -- Commands
|
|||||||
report_error ("%N Input string is a not well formed JSON, expected: : found: " + actual.out)
|
report_error ("%N Input string is a not well formed JSON, expected: : found: " + actual.out)
|
||||||
has_more := False
|
has_more := False
|
||||||
end
|
end
|
||||||
|
|
||||||
l_value := parse
|
l_value := parse
|
||||||
if is_parsed and then (l_value /= Void and l_json_string /= Void) then
|
if is_parsed and then (l_value /= Void and l_json_string /= Void) then
|
||||||
Result.put (l_value, l_json_string)
|
Result.put (l_value, l_json_string)
|
||||||
@@ -286,7 +290,6 @@ feature -- Commands
|
|||||||
do
|
do
|
||||||
create sb.make_empty
|
create sb.make_empty
|
||||||
sb.append_character (actual)
|
sb.append_character (actual)
|
||||||
|
|
||||||
from
|
from
|
||||||
flag := True
|
flag := True
|
||||||
until
|
until
|
||||||
@@ -294,16 +297,13 @@ feature -- Commands
|
|||||||
loop
|
loop
|
||||||
next
|
next
|
||||||
c := actual
|
c := actual
|
||||||
if not has_next or is_close_token (c)
|
if not has_next or is_close_token (c) or c = ',' or c = '%N' or c = '%R' then
|
||||||
or c = ',' or c = '%N' or c = '%R'
|
|
||||||
then
|
|
||||||
flag := False
|
flag := False
|
||||||
previous
|
previous
|
||||||
else
|
else
|
||||||
sb.append_character (c)
|
sb.append_character (c)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_valid_number (sb) then
|
if is_valid_number (sb) then
|
||||||
if sb.is_integer then
|
if sb.is_integer then
|
||||||
create Result.make_integer (sb.to_integer)
|
create Result.make_integer (sb.to_integer)
|
||||||
@@ -324,7 +324,7 @@ feature -- Commands
|
|||||||
l_string: STRING
|
l_string: STRING
|
||||||
do
|
do
|
||||||
l_null := null_id
|
l_null := null_id
|
||||||
l_string := json_substring (index,index + l_null.count - 1)
|
l_string := json_substring (index, index + l_null.count - 1)
|
||||||
if l_string.is_equal (l_null) then
|
if l_string.is_equal (l_null) then
|
||||||
Result := True
|
Result := True
|
||||||
end
|
end
|
||||||
@@ -350,7 +350,7 @@ feature -- Commands
|
|||||||
l_string: STRING
|
l_string: STRING
|
||||||
do
|
do
|
||||||
l_true := true_id
|
l_true := true_id
|
||||||
l_string := json_substring (index,index + l_true.count - 1)
|
l_string := json_substring (index, index + l_true.count - 1)
|
||||||
if l_string.is_equal (l_true) then
|
if l_string.is_equal (l_true) then
|
||||||
Result := True
|
Result := True
|
||||||
end
|
end
|
||||||
@@ -381,7 +381,7 @@ feature {NONE} -- Implementation
|
|||||||
local
|
local
|
||||||
s: detachable STRING
|
s: detachable STRING
|
||||||
c: CHARACTER
|
c: CHARACTER
|
||||||
i,n: INTEGER
|
i, n: INTEGER
|
||||||
do
|
do
|
||||||
create s.make_empty
|
create s.make_empty
|
||||||
n := a_number.count
|
n := a_number.count
|
||||||
@@ -391,21 +391,32 @@ feature {NONE} -- Implementation
|
|||||||
Result := True
|
Result := True
|
||||||
i := 1
|
i := 1
|
||||||
--| "-?"
|
--| "-?"
|
||||||
c := a_number[i]
|
c := a_number [i]
|
||||||
if c = '-' then
|
if c = '-' then
|
||||||
s.extend (c); i := i + 1; c := a_number[i]
|
s.extend (c);
|
||||||
|
i := i + 1;
|
||||||
|
c := a_number [i]
|
||||||
end
|
end
|
||||||
--| "0|[1-9]\d*
|
--| "0|[1-9]\d*
|
||||||
if c.is_digit then
|
if c.is_digit then
|
||||||
if c = '0' then
|
if c = '0' then
|
||||||
--| "0"
|
--| "0"
|
||||||
s.extend (c); i := i + 1; c := a_number[i]
|
s.extend (c);
|
||||||
|
i := i + 1;
|
||||||
|
c := a_number [i]
|
||||||
else
|
else
|
||||||
--| "[1-9]"
|
--| "[1-9]"
|
||||||
s.extend (c); i := i + 1; c := a_number[i]
|
s.extend (c);
|
||||||
|
i := i + 1;
|
||||||
|
c := a_number [i]
|
||||||
--| "\d*"
|
--| "\d*"
|
||||||
from until i > n or not c.is_digit loop
|
from
|
||||||
s.extend (c); i := i + 1; c := a_number[i]
|
until
|
||||||
|
i > n or not c.is_digit
|
||||||
|
loop
|
||||||
|
s.extend (c);
|
||||||
|
i := i + 1;
|
||||||
|
c := a_number [i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -414,10 +425,17 @@ feature {NONE} -- Implementation
|
|||||||
--| "(\.\d+)?"
|
--| "(\.\d+)?"
|
||||||
if c = '.' then
|
if c = '.' then
|
||||||
--| "\.\d+" = "\.\d\d*"
|
--| "\.\d+" = "\.\d\d*"
|
||||||
s.extend (c); i := i + 1; c := a_number[i]
|
s.extend (c);
|
||||||
|
i := i + 1;
|
||||||
|
c := a_number [i]
|
||||||
if c.is_digit then
|
if c.is_digit then
|
||||||
from until i > n or not c.is_digit loop
|
from
|
||||||
s.extend (c); i := i + 1; c := a_number[i]
|
until
|
||||||
|
i > n or not c.is_digit
|
||||||
|
loop
|
||||||
|
s.extend (c);
|
||||||
|
i := i + 1;
|
||||||
|
c := a_number [i]
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Result := False --| expecting digit
|
Result := False --| expecting digit
|
||||||
@@ -427,13 +445,22 @@ feature {NONE} -- Implementation
|
|||||||
if Result then --| "(?:[eE][+-]?\d+)?\b"
|
if Result then --| "(?:[eE][+-]?\d+)?\b"
|
||||||
if c = 'e' or c = 'E' then
|
if c = 'e' or c = 'E' then
|
||||||
--| "[eE][+-]?\d+"
|
--| "[eE][+-]?\d+"
|
||||||
s.extend (c); i := i + 1; c := a_number[i]
|
s.extend (c);
|
||||||
|
i := i + 1;
|
||||||
|
c := a_number [i]
|
||||||
if c = '+' or c = '-' then
|
if c = '+' or c = '-' then
|
||||||
s.extend (c); i := i + 1; c := a_number[i]
|
s.extend (c);
|
||||||
|
i := i + 1;
|
||||||
|
c := a_number [i]
|
||||||
end
|
end
|
||||||
if c.is_digit then
|
if c.is_digit then
|
||||||
from until i > n or not c.is_digit loop
|
from
|
||||||
s.extend (c); i := i + 1; c := a_number[i]
|
until
|
||||||
|
i > n or not c.is_digit
|
||||||
|
loop
|
||||||
|
s.extend (c);
|
||||||
|
i := i + 1;
|
||||||
|
c := a_number [i]
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Result := False --| expecting digit
|
Result := False --| expecting digit
|
||||||
@@ -441,8 +468,13 @@ feature {NONE} -- Implementation
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if Result then --| "\b"
|
if Result then --| "\b"
|
||||||
from until i > n or not c.is_space loop
|
from
|
||||||
s.extend (c); i := i + 1; c := a_number[i]
|
until
|
||||||
|
i > n or not c.is_space
|
||||||
|
loop
|
||||||
|
s.extend (c);
|
||||||
|
i := i + 1;
|
||||||
|
c := a_number [i]
|
||||||
end
|
end
|
||||||
Result := i > n and then s.same_string (a_number)
|
Result := i > n and then s.same_string (a_number)
|
||||||
end
|
end
|
||||||
@@ -454,18 +486,14 @@ feature {NONE} -- Implementation
|
|||||||
local
|
local
|
||||||
i: INTEGER
|
i: INTEGER
|
||||||
do
|
do
|
||||||
if
|
if a_unicode.count = 6 and then a_unicode [1] = '\' and then a_unicode [2] = 'u' then
|
||||||
a_unicode.count = 6 and then
|
|
||||||
a_unicode[1] = '\' and then
|
|
||||||
a_unicode[2] = 'u'
|
|
||||||
then
|
|
||||||
from
|
from
|
||||||
Result := True
|
Result := True
|
||||||
i := 3
|
i := 3
|
||||||
until
|
until
|
||||||
i > 6 or Result = False
|
i > 6 or Result = False
|
||||||
loop
|
loop
|
||||||
inspect a_unicode[i]
|
inspect a_unicode [i]
|
||||||
when '0'..'9', 'a'..'f', 'A'..'F' then
|
when '0'..'9', 'a'..'f', 'A'..'F' then
|
||||||
else
|
else
|
||||||
Result := False
|
Result := False
|
||||||
@@ -493,11 +521,11 @@ feature {NONE} -- Implementation
|
|||||||
Result := has_next
|
Result := has_next
|
||||||
end
|
end
|
||||||
|
|
||||||
is_valid_start_symbol : BOOLEAN
|
is_valid_start_symbol: BOOLEAN
|
||||||
-- expecting `{' or `[' as start symbol
|
-- expecting `{' or `[' as start symbol
|
||||||
do
|
do
|
||||||
if attached representation as s and then s.count > 0 then
|
if attached representation as s and then s.count > 0 then
|
||||||
Result := s[1] = '{' or s[1] = '['
|
Result := s [1] = '{' or s [1] = '['
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -509,5 +537,4 @@ feature {NONE} -- Constants
|
|||||||
|
|
||||||
null_id: STRING = "null"
|
null_id: STRING = "null"
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ feature -- Commands
|
|||||||
from
|
from
|
||||||
c := actual
|
c := actual
|
||||||
until
|
until
|
||||||
(c /= ' ' and c /= '%N' and c /= '%R' and c /= '%U' and c /= '%T' ) or not has_next
|
(c /= ' ' and c /= '%N' and c /= '%R' and c /= '%U' and c /= '%T') or not has_next
|
||||||
loop
|
loop
|
||||||
next
|
next
|
||||||
c := actual
|
c := actual
|
||||||
|
|||||||
@@ -10,13 +10,19 @@ class
|
|||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
j_OBJECT_OPEN: CHARACTER = '{'
|
j_OBJECT_OPEN: CHARACTER = '{'
|
||||||
|
|
||||||
j_ARRAY_OPEN: CHARACTER = '['
|
j_ARRAY_OPEN: CHARACTER = '['
|
||||||
|
|
||||||
j_OBJECT_CLOSE: CHARACTER = '}'
|
j_OBJECT_CLOSE: CHARACTER = '}'
|
||||||
|
|
||||||
j_ARRAY_CLOSE: CHARACTER = ']'
|
j_ARRAY_CLOSE: CHARACTER = ']'
|
||||||
|
|
||||||
j_STRING: CHARACTER = '"'
|
j_STRING: CHARACTER = '"'
|
||||||
|
|
||||||
j_PLUS: CHARACTER = '+'
|
j_PLUS: CHARACTER = '+'
|
||||||
|
|
||||||
j_MINUS: CHARACTER = '-'
|
j_MINUS: CHARACTER = '-'
|
||||||
|
|
||||||
j_DOT: CHARACTER = '.'
|
j_DOT: CHARACTER = '.'
|
||||||
|
|
||||||
feature -- Status report
|
feature -- Status report
|
||||||
@@ -28,7 +34,6 @@ feature -- Status report
|
|||||||
when j_OBJECT_OPEN, j_ARRAY_OPEN, j_STRING, j_PLUS, j_MINUS, j_DOT then
|
when j_OBJECT_OPEN, j_ARRAY_OPEN, j_STRING, j_PLUS, j_MINUS, j_DOT then
|
||||||
Result := True
|
Result := True
|
||||||
else
|
else
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -39,7 +44,6 @@ feature -- Status report
|
|||||||
when j_OBJECT_CLOSE, j_ARRAY_CLOSE, j_STRING then
|
when j_OBJECT_CLOSE, j_ARRAY_CLOSE, j_STRING then
|
||||||
Result := True
|
Result := True
|
||||||
else
|
else
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -58,7 +62,6 @@ feature -- Status report
|
|||||||
when '%F', '%H', '%N', '%R', '%T', '%B', '/', '"' then
|
when '%F', '%H', '%N', '%R', '%T', '%B', '/', '"' then
|
||||||
Result := True
|
Result := True
|
||||||
else
|
else
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -70,7 +73,6 @@ feature -- Status report
|
|||||||
when 'b', 'f', 'n', 'r', 't' then
|
when 'b', 'f', 'n', 'r', 't' then
|
||||||
Result := True
|
Result := True
|
||||||
else
|
else
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ note
|
|||||||
revision: "$Revision: 89185 $"
|
revision: "$Revision: 89185 $"
|
||||||
file: "$HeadURL: $"
|
file: "$HeadURL: $"
|
||||||
|
|
||||||
class SHARED_EJSON
|
class
|
||||||
|
SHARED_EJSON
|
||||||
|
|
||||||
feature
|
feature
|
||||||
|
|
||||||
@@ -24,13 +25,10 @@ feature
|
|||||||
jhtc: JSON_HASH_TABLE_CONVERTER
|
jhtc: JSON_HASH_TABLE_CONVERTER
|
||||||
once
|
once
|
||||||
create Result
|
create Result
|
||||||
|
|
||||||
create jalc.make
|
create jalc.make
|
||||||
Result.add_converter (jalc)
|
Result.add_converter (jalc)
|
||||||
|
|
||||||
create jllc.make
|
create jllc.make
|
||||||
Result.add_converter (jllc)
|
Result.add_converter (jllc)
|
||||||
|
|
||||||
create jhtc.make
|
create jhtc.make
|
||||||
Result.add_converter (jhtc)
|
Result.add_converter (jhtc)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
note
|
note
|
||||||
description : "test_suite application root class"
|
description: "test_suite application root class"
|
||||||
date : "$Date$"
|
date: "$Date$"
|
||||||
revision : "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
class
|
class
|
||||||
APPLICATION
|
APPLICATION
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
ARGUMENTS
|
ARGUMENTS
|
||||||
|
|
||||||
create
|
create
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
class
|
class
|
||||||
AUTHOR
|
AUTHOR
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
class
|
class
|
||||||
BOOK
|
BOOK
|
||||||
|
|
||||||
@@ -9,7 +8,7 @@ feature {NONE} -- Initialization
|
|||||||
|
|
||||||
make (a_title: STRING_32; a_author: AUTHOR; a_isbn: STRING_32)
|
make (a_title: STRING_32; a_author: AUTHOR; a_isbn: STRING_32)
|
||||||
-- Create a book with `a_title' as `title',
|
-- Create a book with `a_title' as `title',
|
||||||
-- `a_author' as `author', and `a_isbn' as `isbn',
|
-- `a_author' as `author', and `a_isbn' as `isbn'.
|
||||||
do
|
do
|
||||||
set_title (a_title)
|
set_title (a_title)
|
||||||
set_author (a_author)
|
set_author (a_author)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ create
|
|||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make (a_name: STRING_32)
|
make (a_name: STRING_32)
|
||||||
-- Create a collection of book with `a_name' as `name'
|
-- Create a book collection with `a_name' as `name'.
|
||||||
do
|
do
|
||||||
set_name (a_name)
|
set_name (a_name)
|
||||||
create book_index.make (10)
|
create book_index.make (10)
|
||||||
@@ -24,7 +24,9 @@ feature -- Access
|
|||||||
-- collection of book.
|
-- collection of book.
|
||||||
do
|
do
|
||||||
create {LINKED_LIST [BOOK]} Result.make
|
create {LINKED_LIST [BOOK]} Result.make
|
||||||
across book_index as it loop
|
across
|
||||||
|
book_index as it
|
||||||
|
loop
|
||||||
Result.append (it.item)
|
Result.append (it.item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -54,7 +56,7 @@ feature -- Change
|
|||||||
local
|
local
|
||||||
l: detachable LIST [BOOK]
|
l: detachable LIST [BOOK]
|
||||||
do
|
do
|
||||||
l := book_index.at (a_book.author.name )
|
l := book_index.at (a_book.author.name)
|
||||||
if l = Void then
|
if l = Void then
|
||||||
create {LINKED_LIST [BOOK]} l.make
|
create {LINKED_LIST [BOOK]} l.make
|
||||||
book_index.put (l, a_book.author.name)
|
book_index.put (l, a_book.author.name)
|
||||||
@@ -65,7 +67,9 @@ feature -- Change
|
|||||||
add_books (book_list: like books)
|
add_books (book_list: like books)
|
||||||
-- Append collection with `book_list'.
|
-- Append collection with `book_list'.
|
||||||
do
|
do
|
||||||
across book_list as it loop
|
across
|
||||||
|
book_list as it
|
||||||
|
loop
|
||||||
add_book (it.item)
|
add_book (it.item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class
|
|||||||
JSON_AUTHOR_CONVERTER
|
JSON_AUTHOR_CONVERTER
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_CONVERTER
|
JSON_CONVERTER
|
||||||
|
|
||||||
create
|
create
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class
|
|||||||
JSON_BOOK_COLLECTION_CONVERTER
|
JSON_BOOK_COLLECTION_CONVERTER
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_CONVERTER
|
JSON_CONVERTER
|
||||||
|
|
||||||
create
|
create
|
||||||
@@ -39,7 +40,6 @@ feature -- Conversion
|
|||||||
then
|
then
|
||||||
create Result.make (l_name)
|
create Result.make (l_name)
|
||||||
create l_books.make
|
create l_books.make
|
||||||
|
|
||||||
across
|
across
|
||||||
l_json_array as it
|
l_json_array as it
|
||||||
until
|
until
|
||||||
@@ -52,7 +52,6 @@ feature -- Conversion
|
|||||||
-- Failed
|
-- Failed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if Result /= Void then
|
if Result /= Void then
|
||||||
Result.add_books (l_books)
|
Result.add_books (l_books)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class
|
|||||||
JSON_BOOK_CONVERTER
|
JSON_BOOK_CONVERTER
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
JSON_CONVERTER
|
JSON_CONVERTER
|
||||||
|
|
||||||
create
|
create
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
note
|
note
|
||||||
description: "Linked list and hash table converters test."
|
description: "Linked list and hash table converters test."
|
||||||
date: "$Date$"
|
date: "$Date$"
|
||||||
@@ -8,6 +7,7 @@ class
|
|||||||
TEST_DS
|
TEST_DS
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
SHARED_EJSON
|
SHARED_EJSON
|
||||||
undefine
|
undefine
|
||||||
default_create
|
default_create
|
||||||
@@ -27,7 +27,6 @@ feature -- Test
|
|||||||
create l.make
|
create l.make
|
||||||
l.force ("foo")
|
l.force ("foo")
|
||||||
l.force ("bar")
|
l.force ("bar")
|
||||||
|
|
||||||
if attached json.value (l) as l_value then
|
if attached json.value (l) as l_value then
|
||||||
s := l_value.representation
|
s := l_value.representation
|
||||||
assert ("JSON array converted to LINKED_LIST", attached {LINKED_LIST [detachable ANY]} json.object (l_value, "LINKED_LIST"))
|
assert ("JSON array converted to LINKED_LIST", attached {LINKED_LIST [detachable ANY]} json.object (l_value, "LINKED_LIST"))
|
||||||
@@ -47,18 +46,15 @@ feature -- Test
|
|||||||
create t.make (2)
|
create t.make (2)
|
||||||
t.put ("foo", "1")
|
t.put ("foo", "1")
|
||||||
t.put ("bar", "2")
|
t.put ("bar", "2")
|
||||||
|
|
||||||
if attached json.value (t) as l_value then
|
if attached json.value (t) as l_value then
|
||||||
s := l_value.representation
|
s := l_value.representation
|
||||||
if attached {HASH_TABLE [ANY, HASHABLE]} json.object (l_value, "HASH_TABLE") as t2 then
|
if attached {HASH_TABLE [ANY, HASHABLE]} json.object (l_value, "HASH_TABLE") as t2 then
|
||||||
|
|
||||||
create l_ucs_key.make_from_string ("1")
|
create l_ucs_key.make_from_string ("1")
|
||||||
if attached {STRING_32} t2 [l_ucs_key] as l_ucs_value then
|
if attached {STRING_32} t2 [l_ucs_key] as l_ucs_value then
|
||||||
assert ("ucs_value.string.is_equal (%"foo%")", l_ucs_value.string.is_equal ("foo"))
|
assert ("ucs_value.string.is_equal (%"foo%")", l_ucs_value.string.is_equal ("foo"))
|
||||||
else
|
else
|
||||||
assert ("ucs_value /= Void", False)
|
assert ("ucs_value /= Void", False)
|
||||||
end
|
end
|
||||||
|
|
||||||
create l_ucs_key.make_from_string ("2")
|
create l_ucs_key.make_from_string ("2")
|
||||||
if attached {STRING_32} t2 [l_ucs_key] as l_ucs_value then
|
if attached {STRING_32} t2 [l_ucs_key] as l_ucs_value then
|
||||||
assert ("ucs_value.string.is_equal (%"bar%")", l_ucs_value.string.is_equal ("bar"))
|
assert ("ucs_value.string.is_equal (%"bar%")", l_ucs_value.string.is_equal ("bar"))
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
class
|
class
|
||||||
TEST_JSON_CORE
|
TEST_JSON_CORE
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
SHARED_EJSON
|
SHARED_EJSON
|
||||||
undefine
|
undefine
|
||||||
default_create
|
default_create
|
||||||
@@ -487,7 +488,6 @@ feature -- Test
|
|||||||
-- Eiffel value -> JSON value -> JSON representation
|
-- Eiffel value -> JSON value -> JSON representation
|
||||||
create jn
|
create jn
|
||||||
jrep := "null"
|
jrep := "null"
|
||||||
|
|
||||||
assert ("jn.representation.is_equal (%"%"null%"%")", jn.representation.is_equal (jrep))
|
assert ("jn.representation.is_equal (%"%"null%"%")", jn.representation.is_equal (jrep))
|
||||||
-- Eiffel value -> JSON value -> JSON representation with factory
|
-- Eiffel value -> JSON value -> JSON representation with factory
|
||||||
if attached {JSON_NULL} json.value (Void) as l_json_null then
|
if attached {JSON_NULL} json.value (Void) as l_json_null then
|
||||||
@@ -515,7 +515,6 @@ feature -- Test
|
|||||||
c := 'a'
|
c := 'a'
|
||||||
-- Eiffel value -> JSON value -> JSON representation
|
-- Eiffel value -> JSON value -> JSON representation
|
||||||
create js.make_json (c.out)
|
create js.make_json (c.out)
|
||||||
|
|
||||||
assert ("js.representation.is_equal (%"%"a%"%")", js.representation.is_equal ("%"a%""))
|
assert ("js.representation.is_equal (%"%"a%"%")", js.representation.is_equal ("%"a%""))
|
||||||
-- Eiffel value -> JSON value -> JSON representation with factory
|
-- Eiffel value -> JSON value -> JSON representation with factory
|
||||||
if attached {JSON_STRING} json.value (c) as l_json_str then
|
if attached {JSON_STRING} json.value (c) as l_json_str then
|
||||||
@@ -612,7 +611,6 @@ feature -- Test
|
|||||||
jrep := "%"foo\\bar%""
|
jrep := "%"foo\\bar%""
|
||||||
create s.make_from_string ("foo\bar")
|
create s.make_from_string ("foo\bar")
|
||||||
create js.make_json (s)
|
create js.make_json (s)
|
||||||
|
|
||||||
assert ("js.representation.same_string (%"%"foo\\bar%"%")", js.representation.same_string (jrep))
|
assert ("js.representation.same_string (%"%"foo\\bar%"%")", js.representation.same_string (jrep))
|
||||||
|
|
||||||
-- Eiffel value -> JSON value -> JSON representation with factory
|
-- Eiffel value -> JSON value -> JSON representation with factory
|
||||||
@@ -631,8 +629,6 @@ feature -- Test
|
|||||||
else
|
else
|
||||||
assert ("parser.parse /= Void", False)
|
assert ("parser.parse /= Void", False)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
jrep := "%"foo\\bar%""
|
jrep := "%"foo\\bar%""
|
||||||
create parser.make_parser (jrep)
|
create parser.make_parser (jrep)
|
||||||
if attached {JSON_STRING} parser.parse as jstring then
|
if attached {JSON_STRING} parser.parse as jstring then
|
||||||
@@ -640,14 +636,12 @@ feature -- Test
|
|||||||
else
|
else
|
||||||
assert ("parser.parse /= Void", False)
|
assert ("parser.parse /= Void", False)
|
||||||
end
|
end
|
||||||
|
create js.make_json_from_string_32 ({STRING_32} "你好")
|
||||||
create js.make_json_from_string_32 ({STRING_32}"%/20320/%/22909/")
|
|
||||||
assert ("escaping unicode string32 %"%%/20320/%%/22909/%" %"\u4F60\u597D%"", js.item.same_string ("\u4F60\u597D"))
|
assert ("escaping unicode string32 %"%%/20320/%%/22909/%" %"\u4F60\u597D%"", js.item.same_string ("\u4F60\u597D"))
|
||||||
|
|
||||||
jrep := "%"\u4F60\u597D%"" --| Ni hao
|
jrep := "%"\u4F60\u597D%"" --| Ni hao
|
||||||
create parser.make_parser (jrep)
|
create parser.make_parser (jrep)
|
||||||
if attached {JSON_STRING} parser.parse as jstring then
|
if attached {JSON_STRING} parser.parse as jstring then
|
||||||
assert ("same unicode string32 %"%%/20320/%%/22909/%"", jstring.unescaped_string_32.same_string ({STRING_32}"%/20320/%/22909/"))
|
assert ("same unicode string32 %"%%/20320/%%/22909/%"", jstring.unescaped_string_32.same_string ({STRING_32} "你好"))
|
||||||
else
|
else
|
||||||
assert ("parser.parse /= Void", False)
|
assert ("parser.parse /= Void", False)
|
||||||
end
|
end
|
||||||
@@ -819,7 +813,7 @@ feature -- Test
|
|||||||
-- Test converting from a JSON value to an Eiffel object based on a
|
-- Test converting from a JSON value to an Eiffel object based on a
|
||||||
-- class for which no JSON converter has been registered.
|
-- class for which no JSON converter has been registered.
|
||||||
local
|
local
|
||||||
gv : detachable ANY
|
gv: detachable ANY
|
||||||
jo: JSON_OBJECT
|
jo: JSON_OBJECT
|
||||||
exception: BOOLEAN
|
exception: BOOLEAN
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
note
|
note
|
||||||
description: "Parsing and converter of book collection test."
|
description: "Parsing and converter of book collection test."
|
||||||
date: "$Date$"
|
date: "$Date$"
|
||||||
@@ -8,6 +7,7 @@ class
|
|||||||
TEST_JSON_CUSTOM_CLASSES
|
TEST_JSON_CUSTOM_CLASSES
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
SHARED_EJSON
|
SHARED_EJSON
|
||||||
undefine
|
undefine
|
||||||
default_create
|
default_create
|
||||||
@@ -34,7 +34,6 @@ feature -- Test
|
|||||||
json.add_converter (jac)
|
json.add_converter (jac)
|
||||||
jrep := "{%"name%":%"Test collection%",%"books%":[{%"title%":%"eJSON: The Definitive Guide%",%"isbn%":%"123123-413243%",%"author%":{%"name%":%"Foo Bar%"}}]}"
|
jrep := "{%"name%":%"Test collection%",%"books%":[{%"title%":%"eJSON: The Definitive Guide%",%"isbn%":%"123123-413243%",%"author%":{%"name%":%"Foo Bar%"}}]}"
|
||||||
create parser.make_parser (jrep)
|
create parser.make_parser (jrep)
|
||||||
|
|
||||||
if attached {JSON_OBJECT} parser.parse as l_json_object then
|
if attached {JSON_OBJECT} parser.parse as l_json_object then
|
||||||
if attached {BOOK_COLLECTION} json.object (l_json_object, "BOOK_COLLECTION") as l_collection then
|
if attached {BOOK_COLLECTION} json.object (l_json_object, "BOOK_COLLECTION") as l_collection then
|
||||||
if attached {JSON_OBJECT} json.value (l_collection) as l_json_object_2 then
|
if attached {JSON_OBJECT} json.value (l_collection) as l_json_object_2 then
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class
|
|||||||
TEST_JSON_SUITE
|
TEST_JSON_SUITE
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
EQA_TEST_SET
|
EQA_TEST_SET
|
||||||
redefine
|
redefine
|
||||||
on_prepare
|
on_prepare
|
||||||
@@ -34,7 +35,7 @@ feature -- Tests Pass
|
|||||||
if attached json_file_from ("pass1.json") as json_file then
|
if attached json_file_from ("pass1.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("pass1.json",parse_json.is_parsed = True)
|
assert ("pass1.json", parse_json.is_parsed = True)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ feature -- Tests Pass
|
|||||||
if attached json_file_from ("pass2.json") as json_file then
|
if attached json_file_from ("pass2.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("pass2.json",parse_json.is_parsed = True)
|
assert ("pass2.json", parse_json.is_parsed = True)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ feature -- Tests Pass
|
|||||||
if attached json_file_from ("pass3.json") as json_file then
|
if attached json_file_from ("pass3.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("pass3.json",parse_json.is_parsed = True)
|
assert ("pass3.json", parse_json.is_parsed = True)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -69,14 +70,10 @@ feature -- Tests Pass
|
|||||||
s: READABLE_STRING_32
|
s: READABLE_STRING_32
|
||||||
do
|
do
|
||||||
s := {STRING_32} "{ %"nihaoma%": %"你好吗\t?%" }"
|
s := {STRING_32} "{ %"nihaoma%": %"你好吗\t?%" }"
|
||||||
|
|
||||||
parse_json := new_json_parser (utf.string_32_to_utf_8_string_8 (s))
|
parse_json := new_json_parser (utf.string_32_to_utf_8_string_8 (s))
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("utf8.pass1.json", parse_json.is_parsed = True)
|
assert ("utf8.pass1.json", parse_json.is_parsed = True)
|
||||||
if
|
if attached {JSON_OBJECT} json_value as jo and then attached {JSON_STRING} jo.item ("nihaoma") as js then
|
||||||
attached {JSON_OBJECT} json_value as jo and then
|
|
||||||
attached {JSON_STRING} jo.item ("nihaoma") as js
|
|
||||||
then
|
|
||||||
assert ("utf8.nihaoma", js.unescaped_string_32.same_string ({STRING_32} "你好吗%T?"))
|
assert ("utf8.nihaoma", js.unescaped_string_32.same_string ({STRING_32} "你好吗%T?"))
|
||||||
else
|
else
|
||||||
assert ("utf8.nihaoma", False)
|
assert ("utf8.nihaoma", False)
|
||||||
@@ -84,6 +81,7 @@ feature -- Tests Pass
|
|||||||
end
|
end
|
||||||
|
|
||||||
feature -- Tests Failures
|
feature -- Tests Failures
|
||||||
|
|
||||||
test_json_fail1
|
test_json_fail1
|
||||||
--
|
--
|
||||||
local
|
local
|
||||||
@@ -92,7 +90,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail1.json") as json_file then
|
if attached json_file_from ("fail1.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail1.json",parse_json.is_parsed = False)
|
assert ("fail1.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -104,7 +102,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail2.json") as json_file then
|
if attached json_file_from ("fail2.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail2.json",parse_json.is_parsed = False)
|
assert ("fail2.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -116,7 +114,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail3.json") as json_file then
|
if attached json_file_from ("fail3.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail3.json",parse_json.is_parsed = False)
|
assert ("fail3.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -128,7 +126,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail4.json") as json_file then
|
if attached json_file_from ("fail4.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail4.json",parse_json.is_parsed = False)
|
assert ("fail4.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -140,11 +138,10 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail5.json") as json_file then
|
if attached json_file_from ("fail5.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail5.json",parse_json.is_parsed = False)
|
assert ("fail5.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
test_json_fail6
|
test_json_fail6
|
||||||
--
|
--
|
||||||
local
|
local
|
||||||
@@ -153,7 +150,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail6.json") as json_file then
|
if attached json_file_from ("fail6.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail6.json",parse_json.is_parsed = False )
|
assert ("fail6.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -165,7 +162,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail7.json") as json_file then
|
if attached json_file_from ("fail7.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail7.json",parse_json.is_parsed = False)
|
assert ("fail7.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -177,11 +174,10 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail8.json") as json_file then
|
if attached json_file_from ("fail8.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail8.json",parse_json.is_parsed = False )
|
assert ("fail8.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
test_json_fail9
|
test_json_fail9
|
||||||
--
|
--
|
||||||
local
|
local
|
||||||
@@ -190,11 +186,10 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail9.json") as json_file then
|
if attached json_file_from ("fail9.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail9.json",parse_json.is_parsed = False)
|
assert ("fail9.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
test_json_fail10
|
test_json_fail10
|
||||||
--
|
--
|
||||||
local
|
local
|
||||||
@@ -203,7 +198,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail10.json") as json_file then
|
if attached json_file_from ("fail10.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail10.json",parse_json.is_parsed = False)
|
assert ("fail10.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -215,7 +210,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail11.json") as json_file then
|
if attached json_file_from ("fail11.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail11.json",parse_json.is_parsed = False)
|
assert ("fail11.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -227,7 +222,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail12.json") as json_file then
|
if attached json_file_from ("fail12.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail12.json",parse_json.is_parsed = False)
|
assert ("fail12.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -239,7 +234,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail13.json") as json_file then
|
if attached json_file_from ("fail13.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail13.json",parse_json.is_parsed = False)
|
assert ("fail13.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -251,7 +246,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail14.json") as json_file then
|
if attached json_file_from ("fail14.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail14.json",parse_json.is_parsed = False)
|
assert ("fail14.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -263,7 +258,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail15.json") as json_file then
|
if attached json_file_from ("fail15.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail15.json",parse_json.is_parsed = False)
|
assert ("fail15.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -275,7 +270,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail16.json") as json_file then
|
if attached json_file_from ("fail16.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail16.json",parse_json.is_parsed = False)
|
assert ("fail16.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -287,7 +282,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail17.json") as json_file then
|
if attached json_file_from ("fail17.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail17.json",parse_json.is_parsed = False)
|
assert ("fail17.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -299,7 +294,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail18.json") as json_file then
|
if attached json_file_from ("fail18.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail18.json",parse_json.is_parsed = True)
|
assert ("fail18.json", parse_json.is_parsed = True)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -311,7 +306,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail19.json") as json_file then
|
if attached json_file_from ("fail19.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail19.json",parse_json.is_parsed = False)
|
assert ("fail19.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -323,7 +318,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail20.json") as json_file then
|
if attached json_file_from ("fail20.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail20.json",parse_json.is_parsed = False)
|
assert ("fail20.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -335,11 +330,10 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail21.json") as json_file then
|
if attached json_file_from ("fail21.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail21.json",parse_json.is_parsed = False)
|
assert ("fail21.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
test_json_fail22
|
test_json_fail22
|
||||||
--
|
--
|
||||||
local
|
local
|
||||||
@@ -348,7 +342,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail22.json") as json_file then
|
if attached json_file_from ("fail22.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail22.json",parse_json.is_parsed = False)
|
assert ("fail22.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -360,7 +354,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail23.json") as json_file then
|
if attached json_file_from ("fail23.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail23.json",parse_json.is_parsed = False)
|
assert ("fail23.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -372,7 +366,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail24.json") as json_file then
|
if attached json_file_from ("fail24.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail24.json",parse_json.is_parsed = False)
|
assert ("fail24.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -384,11 +378,10 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail25.json") as json_file then
|
if attached json_file_from ("fail25.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail25.json",parse_json.is_parsed = False)
|
assert ("fail25.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
test_json_fail26
|
test_json_fail26
|
||||||
--
|
--
|
||||||
local
|
local
|
||||||
@@ -397,11 +390,10 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail26.json") as json_file then
|
if attached json_file_from ("fail26.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail26.json",parse_json.is_parsed = False)
|
assert ("fail26.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
test_json_fail27
|
test_json_fail27
|
||||||
--
|
--
|
||||||
local
|
local
|
||||||
@@ -410,11 +402,10 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail27.json") as json_file then
|
if attached json_file_from ("fail27.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail27.json",parse_json.is_parsed = False)
|
assert ("fail27.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
test_json_fail28
|
test_json_fail28
|
||||||
--
|
--
|
||||||
local
|
local
|
||||||
@@ -423,11 +414,10 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail28.json") as json_file then
|
if attached json_file_from ("fail28.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail28.json",parse_json.is_parsed = False)
|
assert ("fail28.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
test_json_fail29
|
test_json_fail29
|
||||||
--
|
--
|
||||||
local
|
local
|
||||||
@@ -436,11 +426,10 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail29.json") as json_file then
|
if attached json_file_from ("fail29.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail29.json",parse_json.is_parsed = False )
|
assert ("fail29.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
test_json_fail30
|
test_json_fail30
|
||||||
--
|
--
|
||||||
local
|
local
|
||||||
@@ -449,7 +438,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail30.json") as json_file then
|
if attached json_file_from ("fail30.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail30.json",parse_json.is_parsed = False)
|
assert ("fail30.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -461,7 +450,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail31.json") as json_file then
|
if attached json_file_from ("fail31.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail31.json",parse_json.is_parsed = False)
|
assert ("fail31.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -473,7 +462,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail32.json") as json_file then
|
if attached json_file_from ("fail32.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail32.json",parse_json.is_parsed = False)
|
assert ("fail32.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -485,7 +474,7 @@ feature -- Tests Failures
|
|||||||
if attached json_file_from ("fail33.json") as json_file then
|
if attached json_file_from ("fail33.json") as json_file then
|
||||||
parse_json := new_json_parser (json_file)
|
parse_json := new_json_parser (json_file)
|
||||||
json_value := parse_json.parse_json
|
json_value := parse_json.parse_json
|
||||||
assert ("fail33.json",parse_json.is_parsed = False)
|
assert ("fail33.json", parse_json.is_parsed = False)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -504,7 +493,6 @@ feature -- JSON_FROM_FILE
|
|||||||
do
|
do
|
||||||
test_dir := (create {EXECUTION_ENVIRONMENT}).current_working_directory
|
test_dir := (create {EXECUTION_ENVIRONMENT}).current_working_directory
|
||||||
test_dir.append_character ((create {OPERATING_ENVIRONMENT}).directory_separator)
|
test_dir.append_character ((create {OPERATING_ENVIRONMENT}).directory_separator)
|
||||||
|
|
||||||
l_path := test_dir + fn
|
l_path := test_dir + fn
|
||||||
create f.make_with_name (l_path)
|
create f.make_with_name (l_path)
|
||||||
if f.exists then
|
if f.exists then
|
||||||
@@ -536,9 +524,7 @@ feature -- JSON_FROM_FILE
|
|||||||
create Result.make_parser (a_string)
|
create Result.make_parser (a_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
invariant
|
invariant
|
||||||
file_reader /= Void
|
file_reader /= Void
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user