scout 5.7.3.pre.2 → 5.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +4 -0
- data/lib/scout/version.rb +1 -1
- data/vendor/json_pure/.gitignore +12 -0
- data/vendor/json_pure/.travis.yml +20 -0
- data/vendor/json_pure/CHANGES +282 -0
- data/vendor/json_pure/COPYING +58 -0
- data/vendor/json_pure/COPYING-json-jruby +57 -0
- data/vendor/json_pure/GPL +340 -0
- data/vendor/json_pure/Gemfile +11 -0
- data/vendor/json_pure/README-json-jruby.markdown +33 -0
- data/vendor/json_pure/README.rdoc +358 -0
- data/vendor/json_pure/Rakefile +412 -0
- data/vendor/json_pure/TODO +1 -0
- data/vendor/json_pure/VERSION +1 -0
- data/vendor/json_pure/data/example.json +1 -0
- data/vendor/json_pure/data/index.html +38 -0
- data/vendor/json_pure/data/prototype.js +4184 -0
- data/vendor/json_pure/diagrams/.keep +0 -0
- data/vendor/json_pure/ext/json/ext/fbuffer/fbuffer.h +181 -0
- data/vendor/json_pure/ext/json/ext/generator/depend +1 -0
- data/vendor/json_pure/ext/json/ext/generator/extconf.rb +14 -0
- data/vendor/json_pure/ext/json/ext/generator/generator.c +1435 -0
- data/vendor/json_pure/ext/json/ext/generator/generator.h +148 -0
- data/vendor/json_pure/ext/json/ext/parser/depend +1 -0
- data/vendor/json_pure/ext/json/ext/parser/extconf.rb +13 -0
- data/vendor/json_pure/ext/json/ext/parser/parser.c +2204 -0
- data/vendor/json_pure/ext/json/ext/parser/parser.h +77 -0
- data/vendor/json_pure/ext/json/ext/parser/parser.rl +927 -0
- data/vendor/json_pure/install.rb +23 -0
- data/vendor/json_pure/java/src/json/ext/ByteListTranscoder.java +167 -0
- data/vendor/json_pure/java/src/json/ext/Generator.java +444 -0
- data/vendor/json_pure/java/src/json/ext/GeneratorMethods.java +232 -0
- data/vendor/json_pure/java/src/json/ext/GeneratorService.java +43 -0
- data/vendor/json_pure/java/src/json/ext/GeneratorState.java +543 -0
- data/vendor/json_pure/java/src/json/ext/OptionsReader.java +114 -0
- data/vendor/json_pure/java/src/json/ext/Parser.java +2644 -0
- data/vendor/json_pure/java/src/json/ext/Parser.rl +968 -0
- data/vendor/json_pure/java/src/json/ext/ParserService.java +35 -0
- data/vendor/json_pure/java/src/json/ext/RuntimeInfo.java +121 -0
- data/vendor/json_pure/java/src/json/ext/StringDecoder.java +167 -0
- data/vendor/json_pure/java/src/json/ext/StringEncoder.java +106 -0
- data/vendor/json_pure/java/src/json/ext/Utils.java +89 -0
- data/vendor/json_pure/json-java.gemspec +23 -0
- data/vendor/json_pure/json.gemspec +37 -0
- data/vendor/json_pure/json_pure.gemspec +39 -0
- data/vendor/json_pure/lib/json.rb +62 -0
- data/vendor/json_pure/lib/json/add/bigdecimal.rb +28 -0
- data/vendor/json_pure/lib/json/add/complex.rb +22 -0
- data/vendor/json_pure/lib/json/add/core.rb +11 -0
- data/vendor/json_pure/lib/json/add/date.rb +34 -0
- data/vendor/json_pure/lib/json/add/date_time.rb +50 -0
- data/vendor/json_pure/lib/json/add/exception.rb +31 -0
- data/vendor/json_pure/lib/json/add/ostruct.rb +31 -0
- data/vendor/json_pure/lib/json/add/range.rb +29 -0
- data/vendor/json_pure/lib/json/add/rational.rb +22 -0
- data/vendor/json_pure/lib/json/add/regexp.rb +30 -0
- data/vendor/json_pure/lib/json/add/struct.rb +30 -0
- data/vendor/json_pure/lib/json/add/symbol.rb +25 -0
- data/vendor/json_pure/lib/json/add/time.rb +38 -0
- data/vendor/json_pure/lib/json/common.rb +487 -0
- data/vendor/json_pure/lib/json/ext.rb +21 -0
- data/vendor/json_pure/lib/json/ext/.keep +0 -0
- data/vendor/json_pure/lib/json/generic_object.rb +70 -0
- data/vendor/json_pure/lib/json/pure.rb +21 -0
- data/vendor/json_pure/lib/json/pure/generator.rb +522 -0
- data/vendor/json_pure/lib/json/pure/parser.rb +359 -0
- data/vendor/json_pure/lib/json/version.rb +8 -0
- data/vendor/json_pure/tests/fixtures/fail1.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail10.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail11.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail12.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail13.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail14.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail18.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail19.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail2.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail20.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail21.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail22.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail23.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail24.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail25.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail27.json +2 -0
- data/vendor/json_pure/tests/fixtures/fail28.json +2 -0
- data/vendor/json_pure/tests/fixtures/fail3.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail4.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail5.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail6.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail7.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail8.json +1 -0
- data/vendor/json_pure/tests/fixtures/fail9.json +1 -0
- data/vendor/json_pure/tests/fixtures/pass1.json +56 -0
- data/vendor/json_pure/tests/fixtures/pass15.json +1 -0
- data/vendor/json_pure/tests/fixtures/pass16.json +1 -0
- data/vendor/json_pure/tests/fixtures/pass17.json +1 -0
- data/vendor/json_pure/tests/fixtures/pass2.json +1 -0
- data/vendor/json_pure/tests/fixtures/pass26.json +1 -0
- data/vendor/json_pure/tests/fixtures/pass3.json +6 -0
- data/vendor/json_pure/tests/setup_variant.rb +11 -0
- data/vendor/json_pure/tests/test_json.rb +545 -0
- data/vendor/json_pure/tests/test_json_addition.rb +196 -0
- data/vendor/json_pure/tests/test_json_encoding.rb +65 -0
- data/vendor/json_pure/tests/test_json_fixtures.rb +35 -0
- data/vendor/json_pure/tests/test_json_generate.rb +322 -0
- data/vendor/json_pure/tests/test_json_generic_object.rb +75 -0
- data/vendor/json_pure/tests/test_json_string_matching.rb +39 -0
- data/vendor/json_pure/tests/test_json_unicode.rb +72 -0
- data/vendor/json_pure/tools/fuzz.rb +139 -0
- data/vendor/json_pure/tools/server.rb +62 -0
- metadata +111 -4
@@ -0,0 +1,359 @@
|
|
1
|
+
require 'strscan'
|
2
|
+
|
3
|
+
module JSON
|
4
|
+
module Pure
|
5
|
+
# This class implements the JSON parser that is used to parse a JSON string
|
6
|
+
# into a Ruby data structure.
|
7
|
+
class Parser < StringScanner
|
8
|
+
STRING = /" ((?:[^\x0-\x1f"\\] |
|
9
|
+
# escaped special characters:
|
10
|
+
\\["\\\/bfnrt] |
|
11
|
+
\\u[0-9a-fA-F]{4} |
|
12
|
+
# match all but escaped special characters:
|
13
|
+
\\[\x20-\x21\x23-\x2e\x30-\x5b\x5d-\x61\x63-\x65\x67-\x6d\x6f-\x71\x73\x75-\xff])*)
|
14
|
+
"/nx
|
15
|
+
INTEGER = /(-?0|-?[1-9]\d*)/
|
16
|
+
FLOAT = /(-?
|
17
|
+
(?:0|[1-9]\d*)
|
18
|
+
(?:
|
19
|
+
\.\d+(?i:e[+-]?\d+) |
|
20
|
+
\.\d+ |
|
21
|
+
(?i:e[+-]?\d+)
|
22
|
+
)
|
23
|
+
)/x
|
24
|
+
NAN = /NaN/
|
25
|
+
INFINITY = /Infinity/
|
26
|
+
MINUS_INFINITY = /-Infinity/
|
27
|
+
OBJECT_OPEN = /\{/
|
28
|
+
OBJECT_CLOSE = /\}/
|
29
|
+
ARRAY_OPEN = /\[/
|
30
|
+
ARRAY_CLOSE = /\]/
|
31
|
+
PAIR_DELIMITER = /:/
|
32
|
+
COLLECTION_DELIMITER = /,/
|
33
|
+
TRUE = /true/
|
34
|
+
FALSE = /false/
|
35
|
+
NULL = /null/
|
36
|
+
IGNORE = %r(
|
37
|
+
(?:
|
38
|
+
//[^\n\r]*[\n\r]| # line comments
|
39
|
+
/\* # c-style comments
|
40
|
+
(?:
|
41
|
+
[^*/]| # normal chars
|
42
|
+
/[^*]| # slashes that do not start a nested comment
|
43
|
+
\*[^/]| # asterisks that do not end this comment
|
44
|
+
/(?=\*/) # single slash before this comment's end
|
45
|
+
)*
|
46
|
+
\*/ # the End of this comment
|
47
|
+
|[ \t\r\n]+ # whitespaces: space, horicontal tab, lf, cr
|
48
|
+
)+
|
49
|
+
)mx
|
50
|
+
|
51
|
+
UNPARSED = Object.new
|
52
|
+
|
53
|
+
# Creates a new JSON::Pure::Parser instance for the string _source_.
|
54
|
+
#
|
55
|
+
# It will be configured by the _opts_ hash. _opts_ can have the following
|
56
|
+
# keys:
|
57
|
+
# * *max_nesting*: The maximum depth of nesting allowed in the parsed data
|
58
|
+
# structures. Disable depth checking with :max_nesting => false|nil|0,
|
59
|
+
# it defaults to 100.
|
60
|
+
# * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
|
61
|
+
# defiance of RFC 4627 to be parsed by the Parser. This option defaults
|
62
|
+
# to false.
|
63
|
+
# * *symbolize_names*: If set to true, returns symbols for the names
|
64
|
+
# (keys) in a JSON object. Otherwise strings are returned, which is also
|
65
|
+
# the default.
|
66
|
+
# * *create_additions*: If set to true, the Parser creates
|
67
|
+
# additions when if a matching class and create_id was found. This
|
68
|
+
# option defaults to false.
|
69
|
+
# * *object_class*: Defaults to Hash
|
70
|
+
# * *array_class*: Defaults to Array
|
71
|
+
# * *quirks_mode*: Enables quirks_mode for parser, that is for example
|
72
|
+
# parsing single JSON values instead of documents is possible.
|
73
|
+
def initialize(source, opts = {})
|
74
|
+
opts ||= {}
|
75
|
+
unless @quirks_mode = opts[:quirks_mode]
|
76
|
+
source = convert_encoding source
|
77
|
+
end
|
78
|
+
super source
|
79
|
+
if !opts.key?(:max_nesting) # defaults to 100
|
80
|
+
@max_nesting = 100
|
81
|
+
elsif opts[:max_nesting]
|
82
|
+
@max_nesting = opts[:max_nesting]
|
83
|
+
else
|
84
|
+
@max_nesting = 0
|
85
|
+
end
|
86
|
+
@allow_nan = !!opts[:allow_nan]
|
87
|
+
@symbolize_names = !!opts[:symbolize_names]
|
88
|
+
if opts.key?(:create_additions)
|
89
|
+
@create_additions = !!opts[:create_additions]
|
90
|
+
else
|
91
|
+
@create_additions = false
|
92
|
+
end
|
93
|
+
@create_id = @create_additions ? JSON.create_id : nil
|
94
|
+
@object_class = opts[:object_class] || Hash
|
95
|
+
@array_class = opts[:array_class] || Array
|
96
|
+
@match_string = opts[:match_string]
|
97
|
+
end
|
98
|
+
|
99
|
+
alias source string
|
100
|
+
|
101
|
+
def quirks_mode?
|
102
|
+
!!@quirks_mode
|
103
|
+
end
|
104
|
+
|
105
|
+
def reset
|
106
|
+
super
|
107
|
+
@current_nesting = 0
|
108
|
+
end
|
109
|
+
|
110
|
+
# Parses the current JSON string _source_ and returns the complete data
|
111
|
+
# structure as a result.
|
112
|
+
def parse
|
113
|
+
reset
|
114
|
+
obj = nil
|
115
|
+
if @quirks_mode
|
116
|
+
while !eos? && skip(IGNORE)
|
117
|
+
end
|
118
|
+
if eos?
|
119
|
+
raise ParserError, "source did not contain any JSON!"
|
120
|
+
else
|
121
|
+
obj = parse_value
|
122
|
+
obj == UNPARSED and raise ParserError, "source did not contain any JSON!"
|
123
|
+
end
|
124
|
+
else
|
125
|
+
until eos?
|
126
|
+
case
|
127
|
+
when scan(OBJECT_OPEN)
|
128
|
+
obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
|
129
|
+
@current_nesting = 1
|
130
|
+
obj = parse_object
|
131
|
+
when scan(ARRAY_OPEN)
|
132
|
+
obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
|
133
|
+
@current_nesting = 1
|
134
|
+
obj = parse_array
|
135
|
+
when skip(IGNORE)
|
136
|
+
;
|
137
|
+
else
|
138
|
+
raise ParserError, "source '#{peek(20)}' not in JSON!"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
obj or raise ParserError, "source did not contain any JSON!"
|
142
|
+
end
|
143
|
+
obj
|
144
|
+
end
|
145
|
+
|
146
|
+
private
|
147
|
+
|
148
|
+
def convert_encoding(source)
|
149
|
+
if source.respond_to?(:to_str)
|
150
|
+
source = source.to_str
|
151
|
+
else
|
152
|
+
raise TypeError, "#{source.inspect} is not like a string"
|
153
|
+
end
|
154
|
+
if defined?(::Encoding)
|
155
|
+
if source.encoding == ::Encoding::ASCII_8BIT
|
156
|
+
b = source[0, 4].bytes.to_a
|
157
|
+
source =
|
158
|
+
case
|
159
|
+
when b.size >= 4 && b[0] == 0 && b[1] == 0 && b[2] == 0
|
160
|
+
source.dup.force_encoding(::Encoding::UTF_32BE).encode!(::Encoding::UTF_8)
|
161
|
+
when b.size >= 4 && b[0] == 0 && b[2] == 0
|
162
|
+
source.dup.force_encoding(::Encoding::UTF_16BE).encode!(::Encoding::UTF_8)
|
163
|
+
when b.size >= 4 && b[1] == 0 && b[2] == 0 && b[3] == 0
|
164
|
+
source.dup.force_encoding(::Encoding::UTF_32LE).encode!(::Encoding::UTF_8)
|
165
|
+
when b.size >= 4 && b[1] == 0 && b[3] == 0
|
166
|
+
source.dup.force_encoding(::Encoding::UTF_16LE).encode!(::Encoding::UTF_8)
|
167
|
+
else
|
168
|
+
source.dup
|
169
|
+
end
|
170
|
+
else
|
171
|
+
source = source.encode(::Encoding::UTF_8)
|
172
|
+
end
|
173
|
+
source.force_encoding(::Encoding::ASCII_8BIT)
|
174
|
+
else
|
175
|
+
b = source
|
176
|
+
source =
|
177
|
+
case
|
178
|
+
when b.size >= 4 && b[0] == 0 && b[1] == 0 && b[2] == 0
|
179
|
+
JSON.iconv('utf-8', 'utf-32be', b)
|
180
|
+
when b.size >= 4 && b[0] == 0 && b[2] == 0
|
181
|
+
JSON.iconv('utf-8', 'utf-16be', b)
|
182
|
+
when b.size >= 4 && b[1] == 0 && b[2] == 0 && b[3] == 0
|
183
|
+
JSON.iconv('utf-8', 'utf-32le', b)
|
184
|
+
when b.size >= 4 && b[1] == 0 && b[3] == 0
|
185
|
+
JSON.iconv('utf-8', 'utf-16le', b)
|
186
|
+
else
|
187
|
+
b
|
188
|
+
end
|
189
|
+
end
|
190
|
+
source
|
191
|
+
end
|
192
|
+
|
193
|
+
# Unescape characters in strings.
|
194
|
+
UNESCAPE_MAP = Hash.new { |h, k| h[k] = k.chr }
|
195
|
+
UNESCAPE_MAP.update({
|
196
|
+
?" => '"',
|
197
|
+
?\\ => '\\',
|
198
|
+
?/ => '/',
|
199
|
+
?b => "\b",
|
200
|
+
?f => "\f",
|
201
|
+
?n => "\n",
|
202
|
+
?r => "\r",
|
203
|
+
?t => "\t",
|
204
|
+
?u => nil,
|
205
|
+
})
|
206
|
+
|
207
|
+
EMPTY_8BIT_STRING = ''
|
208
|
+
if ::String.method_defined?(:encode)
|
209
|
+
EMPTY_8BIT_STRING.force_encoding Encoding::ASCII_8BIT
|
210
|
+
end
|
211
|
+
|
212
|
+
def parse_string
|
213
|
+
if scan(STRING)
|
214
|
+
return '' if self[1].empty?
|
215
|
+
string = self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c|
|
216
|
+
if u = UNESCAPE_MAP[$&[1]]
|
217
|
+
u
|
218
|
+
else # \uXXXX
|
219
|
+
bytes = EMPTY_8BIT_STRING.dup
|
220
|
+
i = 0
|
221
|
+
while c[6 * i] == ?\\ && c[6 * i + 1] == ?u
|
222
|
+
bytes << c[6 * i + 2, 2].to_i(16) << c[6 * i + 4, 2].to_i(16)
|
223
|
+
i += 1
|
224
|
+
end
|
225
|
+
JSON.iconv('utf-8', 'utf-16be', bytes)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
if string.respond_to?(:force_encoding)
|
229
|
+
string.force_encoding(::Encoding::UTF_8)
|
230
|
+
end
|
231
|
+
if @create_additions and @match_string
|
232
|
+
for (regexp, klass) in @match_string
|
233
|
+
klass.json_creatable? or next
|
234
|
+
string =~ regexp and return klass.json_create(string)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
string
|
238
|
+
else
|
239
|
+
UNPARSED
|
240
|
+
end
|
241
|
+
rescue => e
|
242
|
+
raise ParserError, "Caught #{e.class} at '#{peek(20)}': #{e}"
|
243
|
+
end
|
244
|
+
|
245
|
+
def parse_value
|
246
|
+
case
|
247
|
+
when scan(FLOAT)
|
248
|
+
Float(self[1])
|
249
|
+
when scan(INTEGER)
|
250
|
+
Integer(self[1])
|
251
|
+
when scan(TRUE)
|
252
|
+
true
|
253
|
+
when scan(FALSE)
|
254
|
+
false
|
255
|
+
when scan(NULL)
|
256
|
+
nil
|
257
|
+
when (string = parse_string) != UNPARSED
|
258
|
+
string
|
259
|
+
when scan(ARRAY_OPEN)
|
260
|
+
@current_nesting += 1
|
261
|
+
ary = parse_array
|
262
|
+
@current_nesting -= 1
|
263
|
+
ary
|
264
|
+
when scan(OBJECT_OPEN)
|
265
|
+
@current_nesting += 1
|
266
|
+
obj = parse_object
|
267
|
+
@current_nesting -= 1
|
268
|
+
obj
|
269
|
+
when @allow_nan && scan(NAN)
|
270
|
+
NaN
|
271
|
+
when @allow_nan && scan(INFINITY)
|
272
|
+
Infinity
|
273
|
+
when @allow_nan && scan(MINUS_INFINITY)
|
274
|
+
MinusInfinity
|
275
|
+
else
|
276
|
+
UNPARSED
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def parse_array
|
281
|
+
raise NestingError, "nesting of #@current_nesting is too deep" if
|
282
|
+
@max_nesting.nonzero? && @current_nesting > @max_nesting
|
283
|
+
result = @array_class.new
|
284
|
+
delim = false
|
285
|
+
until eos?
|
286
|
+
case
|
287
|
+
when (value = parse_value) != UNPARSED
|
288
|
+
delim = false
|
289
|
+
result << value
|
290
|
+
skip(IGNORE)
|
291
|
+
if scan(COLLECTION_DELIMITER)
|
292
|
+
delim = true
|
293
|
+
elsif match?(ARRAY_CLOSE)
|
294
|
+
;
|
295
|
+
else
|
296
|
+
raise ParserError, "expected ',' or ']' in array at '#{peek(20)}'!"
|
297
|
+
end
|
298
|
+
when scan(ARRAY_CLOSE)
|
299
|
+
if delim
|
300
|
+
raise ParserError, "expected next element in array at '#{peek(20)}'!"
|
301
|
+
end
|
302
|
+
break
|
303
|
+
when skip(IGNORE)
|
304
|
+
;
|
305
|
+
else
|
306
|
+
raise ParserError, "unexpected token in array at '#{peek(20)}'!"
|
307
|
+
end
|
308
|
+
end
|
309
|
+
result
|
310
|
+
end
|
311
|
+
|
312
|
+
def parse_object
|
313
|
+
raise NestingError, "nesting of #@current_nesting is too deep" if
|
314
|
+
@max_nesting.nonzero? && @current_nesting > @max_nesting
|
315
|
+
result = @object_class.new
|
316
|
+
delim = false
|
317
|
+
until eos?
|
318
|
+
case
|
319
|
+
when (string = parse_string) != UNPARSED
|
320
|
+
skip(IGNORE)
|
321
|
+
unless scan(PAIR_DELIMITER)
|
322
|
+
raise ParserError, "expected ':' in object at '#{peek(20)}'!"
|
323
|
+
end
|
324
|
+
skip(IGNORE)
|
325
|
+
unless (value = parse_value).equal? UNPARSED
|
326
|
+
result[@symbolize_names ? string.to_sym : string] = value
|
327
|
+
delim = false
|
328
|
+
skip(IGNORE)
|
329
|
+
if scan(COLLECTION_DELIMITER)
|
330
|
+
delim = true
|
331
|
+
elsif match?(OBJECT_CLOSE)
|
332
|
+
;
|
333
|
+
else
|
334
|
+
raise ParserError, "expected ',' or '}' in object at '#{peek(20)}'!"
|
335
|
+
end
|
336
|
+
else
|
337
|
+
raise ParserError, "expected value in object at '#{peek(20)}'!"
|
338
|
+
end
|
339
|
+
when scan(OBJECT_CLOSE)
|
340
|
+
if delim
|
341
|
+
raise ParserError, "expected next name, value pair in object at '#{peek(20)}'!"
|
342
|
+
end
|
343
|
+
if @create_additions and klassname = result[@create_id]
|
344
|
+
klass = JSON.deep_const_get klassname
|
345
|
+
break unless klass and klass.json_creatable?
|
346
|
+
result = klass.json_create(result)
|
347
|
+
end
|
348
|
+
break
|
349
|
+
when skip(IGNORE)
|
350
|
+
;
|
351
|
+
else
|
352
|
+
raise ParserError, "unexpected token in object at '#{peek(20)}'!"
|
353
|
+
end
|
354
|
+
end
|
355
|
+
result
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
"A JSON payload should be an object or array, not a string."
|
@@ -0,0 +1 @@
|
|
1
|
+
{"Extra value after close": true} "misplaced quoted value"
|
@@ -0,0 +1 @@
|
|
1
|
+
{"Illegal expression": 1 + 2}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"Illegal invocation": alert()}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"Numbers cannot have leading zeroes": 013}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"Numbers cannot be hex": 0x14}
|
@@ -0,0 +1 @@
|
|
1
|
+
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
|
@@ -0,0 +1 @@
|
|
1
|
+
{"Missing colon" null}
|
@@ -0,0 +1 @@
|
|
1
|
+
["Unclosed array"
|
@@ -0,0 +1 @@
|
|
1
|
+
{"Double colon":: null}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"Comma instead of colon", null}
|
@@ -0,0 +1 @@
|
|
1
|
+
["Colon instead of comma": false]
|
@@ -0,0 +1 @@
|
|
1
|
+
["Bad value", truth]
|
@@ -0,0 +1 @@
|
|
1
|
+
['single quote']
|
@@ -0,0 +1 @@
|
|
1
|
+
["tab character in string "]
|
@@ -0,0 +1 @@
|
|
1
|
+
{unquoted_key: "keys must be quoted"}
|
@@ -0,0 +1 @@
|
|
1
|
+
["extra comma",]
|
@@ -0,0 +1 @@
|
|
1
|
+
["double extra comma",,]
|
@@ -0,0 +1 @@
|
|
1
|
+
[ , "<-- missing value"]
|
@@ -0,0 +1 @@
|
|
1
|
+
["Comma after the close"],
|
@@ -0,0 +1 @@
|
|
1
|
+
["Extra close"]]
|
@@ -0,0 +1 @@
|
|
1
|
+
{"Extra comma": true,}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
[
|
2
|
+
"JSON Test Pattern pass1",
|
3
|
+
{"object with 1 member":["array with 1 element"]},
|
4
|
+
{},
|
5
|
+
[],
|
6
|
+
-42,
|
7
|
+
true,
|
8
|
+
false,
|
9
|
+
null,
|
10
|
+
{
|
11
|
+
"integer": 1234567890,
|
12
|
+
"real": -9876.543210,
|
13
|
+
"e": 0.123456789e-12,
|
14
|
+
"E": 1.234567890E+34,
|
15
|
+
"": 23456789012E666,
|
16
|
+
"zero": 0,
|
17
|
+
"one": 1,
|
18
|
+
"space": " ",
|
19
|
+
"quote": "\"",
|
20
|
+
"backslash": "\\",
|
21
|
+
"controls": "\b\f\n\r\t",
|
22
|
+
"slash": "/ & \/",
|
23
|
+
"alpha": "abcdefghijklmnopqrstuvwyz",
|
24
|
+
"ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
|
25
|
+
"digit": "0123456789",
|
26
|
+
"special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?",
|
27
|
+
"hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
|
28
|
+
"true": true,
|
29
|
+
"false": false,
|
30
|
+
"null": null,
|
31
|
+
"array":[ ],
|
32
|
+
"object":{ },
|
33
|
+
"address": "50 St. James Street",
|
34
|
+
"url": "http://www.JSON.org/",
|
35
|
+
"comment": "// /* <!-- --",
|
36
|
+
"# -- --> */": " ",
|
37
|
+
" s p a c e d " :[1,2 , 3
|
38
|
+
|
39
|
+
,
|
40
|
+
|
41
|
+
4 , 5 , 6 ,7 ],
|
42
|
+
"compact": [1,2,3,4,5,6,7],
|
43
|
+
"jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
|
44
|
+
"quotes": "" \u0022 %22 0x22 034 "",
|
45
|
+
"\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"
|
46
|
+
: "A key can be any string"
|
47
|
+
},
|
48
|
+
0.5 ,98.6
|
49
|
+
,
|
50
|
+
99.44
|
51
|
+
,
|
52
|
+
|
53
|
+
1066
|
54
|
+
|
55
|
+
|
56
|
+
,"rosebud"]
|