oj 3.13.9 → 3.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +101 -0
- data/README.md +13 -2
- data/ext/oj/buf.h +11 -6
- data/ext/oj/cache.c +25 -24
- data/ext/oj/cache8.c +10 -9
- data/ext/oj/circarray.c +8 -6
- data/ext/oj/circarray.h +2 -2
- data/ext/oj/code.c +19 -33
- data/ext/oj/code.h +2 -2
- data/ext/oj/compat.c +20 -60
- data/ext/oj/custom.c +76 -155
- data/ext/oj/debug.c +3 -9
- data/ext/oj/dump.c +203 -213
- data/ext/oj/dump.h +26 -12
- data/ext/oj/dump_compat.c +565 -642
- data/ext/oj/dump_leaf.c +17 -63
- data/ext/oj/dump_object.c +59 -181
- data/ext/oj/dump_strict.c +24 -48
- data/ext/oj/encoder.c +43 -0
- data/ext/oj/err.c +2 -13
- data/ext/oj/err.h +9 -12
- data/ext/oj/extconf.rb +18 -7
- data/ext/oj/fast.c +83 -108
- data/ext/oj/intern.c +52 -50
- data/ext/oj/intern.h +4 -8
- data/ext/oj/mem.c +318 -0
- data/ext/oj/mem.h +53 -0
- data/ext/oj/mimic_json.c +104 -81
- data/ext/oj/object.c +50 -67
- data/ext/oj/odd.c +89 -67
- data/ext/oj/odd.h +15 -15
- data/ext/oj/oj.c +171 -106
- data/ext/oj/oj.h +96 -74
- data/ext/oj/parse.c +169 -189
- data/ext/oj/parse.h +23 -24
- data/ext/oj/parser.c +89 -34
- data/ext/oj/parser.h +20 -9
- data/ext/oj/rails.c +86 -151
- data/ext/oj/rails.h +1 -1
- data/ext/oj/reader.c +12 -15
- data/ext/oj/reader.h +4 -2
- data/ext/oj/resolve.c +3 -4
- data/ext/oj/rxclass.c +6 -5
- data/ext/oj/rxclass.h +1 -1
- data/ext/oj/saj.c +21 -32
- data/ext/oj/saj2.c +329 -93
- data/ext/oj/saj2.h +23 -0
- data/ext/oj/scp.c +3 -14
- data/ext/oj/sparse.c +26 -70
- data/ext/oj/stream_writer.c +12 -22
- data/ext/oj/strict.c +20 -52
- data/ext/oj/string_writer.c +21 -22
- data/ext/oj/trace.h +31 -4
- data/ext/oj/usual.c +105 -150
- data/ext/oj/usual.h +68 -0
- data/ext/oj/util.h +1 -1
- data/ext/oj/val_stack.c +1 -1
- data/ext/oj/val_stack.h +8 -7
- data/ext/oj/validate.c +21 -26
- data/ext/oj/wab.c +32 -69
- data/lib/oj/active_support_helper.rb +1 -3
- data/lib/oj/bag.rb +7 -1
- data/lib/oj/easy_hash.rb +4 -5
- data/lib/oj/error.rb +0 -1
- data/lib/oj/json.rb +162 -150
- data/lib/oj/mimic.rb +6 -2
- data/lib/oj/saj.rb +20 -6
- data/lib/oj/state.rb +9 -6
- data/lib/oj/version.rb +1 -2
- data/lib/oj.rb +2 -0
- data/pages/Compatibility.md +1 -1
- data/pages/InstallOptions.md +20 -0
- data/pages/JsonGem.md +15 -0
- data/pages/Modes.md +6 -3
- data/pages/Options.md +10 -0
- data/pages/Rails.md +12 -0
- data/test/_test_active.rb +8 -9
- data/test/_test_active_mimic.rb +7 -8
- data/test/_test_mimic_rails.rb +17 -20
- data/test/activerecord/result_test.rb +5 -6
- data/test/{activesupport5 → activesupport7}/abstract_unit.rb +16 -12
- data/test/{activesupport5 → activesupport7}/decoding_test.rb +2 -10
- data/test/{activesupport5 → activesupport7}/encoding_test.rb +20 -34
- data/test/{activesupport5 → activesupport7}/encoding_test_cases.rb +6 -0
- data/test/{activesupport5 → activesupport7}/time_zone_test_helpers.rb +8 -0
- data/test/files.rb +15 -15
- data/test/foo.rb +15 -15
- data/test/helper.rb +11 -8
- data/test/isolated/shared.rb +3 -2
- data/test/json_gem/json_addition_test.rb +2 -2
- data/test/json_gem/json_common_interface_test.rb +8 -6
- data/test/json_gem/json_encoding_test.rb +0 -0
- data/test/json_gem/json_ext_parser_test.rb +1 -0
- data/test/json_gem/json_fixtures_test.rb +3 -2
- data/test/json_gem/json_generator_test.rb +49 -37
- data/test/json_gem/json_generic_object_test.rb +11 -11
- data/test/json_gem/json_parser_test.rb +54 -47
- data/test/json_gem/json_string_matching_test.rb +9 -9
- data/test/json_gem/test_helper.rb +7 -3
- data/test/mem.rb +13 -12
- data/test/perf.rb +21 -26
- data/test/perf_compat.rb +31 -33
- data/test/perf_dump.rb +50 -0
- data/test/perf_fast.rb +80 -82
- data/test/perf_file.rb +27 -29
- data/test/perf_object.rb +65 -69
- data/test/perf_once.rb +12 -11
- data/test/perf_parser.rb +42 -48
- data/test/perf_saj.rb +46 -54
- data/test/perf_scp.rb +57 -69
- data/test/perf_simple.rb +41 -39
- data/test/perf_strict.rb +68 -70
- data/test/perf_wab.rb +67 -69
- data/test/prec.rb +3 -3
- data/test/sample/change.rb +0 -1
- data/test/sample/dir.rb +0 -1
- data/test/sample/doc.rb +0 -1
- data/test/sample/file.rb +0 -1
- data/test/sample/group.rb +0 -1
- data/test/sample/hasprops.rb +0 -1
- data/test/sample/layer.rb +0 -1
- data/test/sample/rect.rb +0 -1
- data/test/sample/shape.rb +0 -1
- data/test/sample/text.rb +0 -1
- data/test/sample.rb +16 -16
- data/test/sample_json.rb +8 -8
- data/test/test_compat.rb +95 -43
- data/test/test_custom.rb +72 -51
- data/test/test_debian.rb +7 -10
- data/test/test_fast.rb +102 -87
- data/test/test_file.rb +41 -30
- data/test/test_gc.rb +16 -5
- data/test/test_generate.rb +5 -5
- data/test/test_hash.rb +4 -4
- data/test/test_integer_range.rb +9 -9
- data/test/test_null.rb +20 -20
- data/test/test_object.rb +85 -96
- data/test/test_parser.rb +6 -22
- data/test/test_parser_debug.rb +27 -0
- data/test/test_parser_saj.rb +115 -23
- data/test/test_parser_usual.rb +6 -6
- data/test/test_rails.rb +2 -2
- data/test/test_saj.rb +10 -8
- data/test/test_scp.rb +37 -39
- data/test/test_strict.rb +40 -32
- data/test/test_various.rb +163 -84
- data/test/test_wab.rb +48 -44
- data/test/test_writer.rb +47 -47
- data/test/tests.rb +13 -5
- data/test/tests_mimic.rb +12 -3
- data/test/tests_mimic_addition.rb +12 -3
- metadata +34 -144
- data/test/activesupport4/decoding_test.rb +0 -108
- data/test/activesupport4/encoding_test.rb +0 -531
- data/test/activesupport4/test_helper.rb +0 -41
- data/test/activesupport5/test_helper.rb +0 -72
- data/test/bar.rb +0 -16
- data/test/baz.rb +0 -16
- data/test/bug.rb +0 -16
- data/test/zoo.rb +0 -13
metadata
CHANGED
@@ -1,35 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rake-compiler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.9'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '2.0'
|
23
|
-
type: :development
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0.9'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '2.0'
|
33
13
|
- !ruby/object:Gem::Dependency
|
34
14
|
name: minitest
|
35
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,33 +25,39 @@ dependencies:
|
|
45
25
|
- !ruby/object:Gem::Version
|
46
26
|
version: '5'
|
47
27
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
28
|
+
name: rake-compiler
|
49
29
|
requirement: !ruby/object:Gem::Requirement
|
50
30
|
requirements:
|
51
|
-
- - "
|
31
|
+
- - ">="
|
52
32
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
33
|
+
version: '0.9'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '2.0'
|
54
37
|
type: :development
|
55
38
|
prerelease: false
|
56
39
|
version_requirements: !ruby/object:Gem::Requirement
|
57
40
|
requirements:
|
58
|
-
- - "
|
41
|
+
- - ">="
|
59
42
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
43
|
+
version: '0.9'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2.0'
|
61
47
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
48
|
+
name: test-unit
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|
64
50
|
requirements:
|
65
51
|
- - "~>"
|
66
52
|
- !ruby/object:Gem::Version
|
67
|
-
version: '0'
|
53
|
+
version: '3.0'
|
68
54
|
type: :development
|
69
55
|
prerelease: false
|
70
56
|
version_requirements: !ruby/object:Gem::Requirement
|
71
57
|
requirements:
|
72
58
|
- - "~>"
|
73
59
|
- !ruby/object:Gem::Version
|
74
|
-
version: '0'
|
60
|
+
version: '3.0'
|
75
61
|
description: The fastest JSON parser and object serializer.
|
76
62
|
email: peter@ohler.com
|
77
63
|
executables: []
|
@@ -86,6 +72,7 @@ extra_rdoc_files:
|
|
86
72
|
- pages/Compatibility.md
|
87
73
|
- pages/Custom.md
|
88
74
|
- pages/Encoding.md
|
75
|
+
- pages/InstallOptions.md
|
89
76
|
- pages/JsonGem.md
|
90
77
|
- pages/Modes.md
|
91
78
|
- pages/Options.md
|
@@ -117,12 +104,15 @@ files:
|
|
117
104
|
- ext/oj/dump_object.c
|
118
105
|
- ext/oj/dump_strict.c
|
119
106
|
- ext/oj/encode.h
|
107
|
+
- ext/oj/encoder.c
|
120
108
|
- ext/oj/err.c
|
121
109
|
- ext/oj/err.h
|
122
110
|
- ext/oj/extconf.rb
|
123
111
|
- ext/oj/fast.c
|
124
112
|
- ext/oj/intern.c
|
125
113
|
- ext/oj/intern.h
|
114
|
+
- ext/oj/mem.c
|
115
|
+
- ext/oj/mem.h
|
126
116
|
- ext/oj/mimic_json.c
|
127
117
|
- ext/oj/object.c
|
128
118
|
- ext/oj/odd.c
|
@@ -143,6 +133,7 @@ files:
|
|
143
133
|
- ext/oj/rxclass.h
|
144
134
|
- ext/oj/saj.c
|
145
135
|
- ext/oj/saj2.c
|
136
|
+
- ext/oj/saj2.h
|
146
137
|
- ext/oj/scp.c
|
147
138
|
- ext/oj/sparse.c
|
148
139
|
- ext/oj/stream_writer.c
|
@@ -151,6 +142,7 @@ files:
|
|
151
142
|
- ext/oj/trace.c
|
152
143
|
- ext/oj/trace.h
|
153
144
|
- ext/oj/usual.c
|
145
|
+
- ext/oj/usual.h
|
154
146
|
- ext/oj/util.c
|
155
147
|
- ext/oj/util.h
|
156
148
|
- ext/oj/val_stack.c
|
@@ -172,6 +164,7 @@ files:
|
|
172
164
|
- pages/Compatibility.md
|
173
165
|
- pages/Custom.md
|
174
166
|
- pages/Encoding.md
|
167
|
+
- pages/InstallOptions.md
|
175
168
|
- pages/JsonGem.md
|
176
169
|
- pages/Modes.md
|
177
170
|
- pages/Options.md
|
@@ -183,15 +176,6 @@ files:
|
|
183
176
|
- test/_test_active_mimic.rb
|
184
177
|
- test/_test_mimic_rails.rb
|
185
178
|
- test/activerecord/result_test.rb
|
186
|
-
- test/activesupport4/decoding_test.rb
|
187
|
-
- test/activesupport4/encoding_test.rb
|
188
|
-
- test/activesupport4/test_helper.rb
|
189
|
-
- test/activesupport5/abstract_unit.rb
|
190
|
-
- test/activesupport5/decoding_test.rb
|
191
|
-
- test/activesupport5/encoding_test.rb
|
192
|
-
- test/activesupport5/encoding_test_cases.rb
|
193
|
-
- test/activesupport5/test_helper.rb
|
194
|
-
- test/activesupport5/time_zone_test_helpers.rb
|
195
179
|
- test/activesupport6/abstract_unit.rb
|
196
180
|
- test/activesupport6/decoding_test.rb
|
197
181
|
- test/activesupport6/encoding_test.rb
|
@@ -199,9 +183,11 @@ files:
|
|
199
183
|
- test/activesupport6/test_common.rb
|
200
184
|
- test/activesupport6/test_helper.rb
|
201
185
|
- test/activesupport6/time_zone_test_helpers.rb
|
202
|
-
- test/
|
203
|
-
- test/
|
204
|
-
- test/
|
186
|
+
- test/activesupport7/abstract_unit.rb
|
187
|
+
- test/activesupport7/decoding_test.rb
|
188
|
+
- test/activesupport7/encoding_test.rb
|
189
|
+
- test/activesupport7/encoding_test_cases.rb
|
190
|
+
- test/activesupport7/time_zone_test_helpers.rb
|
205
191
|
- test/files.rb
|
206
192
|
- test/foo.rb
|
207
193
|
- test/helper.rb
|
@@ -227,6 +213,7 @@ files:
|
|
227
213
|
- test/mem.rb
|
228
214
|
- test/perf.rb
|
229
215
|
- test/perf_compat.rb
|
216
|
+
- test/perf_dump.rb
|
230
217
|
- test/perf_fast.rb
|
231
218
|
- test/perf_file.rb
|
232
219
|
- test/perf_object.rb
|
@@ -264,6 +251,7 @@ files:
|
|
264
251
|
- test/test_null.rb
|
265
252
|
- test/test_object.rb
|
266
253
|
- test/test_parser.rb
|
254
|
+
- test/test_parser_debug.rb
|
267
255
|
- test/test_parser_saj.rb
|
268
256
|
- test/test_parser_usual.rb
|
269
257
|
- test/test_rails.rb
|
@@ -276,7 +264,6 @@ files:
|
|
276
264
|
- test/tests.rb
|
277
265
|
- test/tests_mimic.rb
|
278
266
|
- test/tests_mimic_addition.rb
|
279
|
-
- test/zoo.rb
|
280
267
|
homepage: http://www.ohler.com/oj
|
281
268
|
licenses:
|
282
269
|
- MIT
|
@@ -287,6 +274,7 @@ metadata:
|
|
287
274
|
homepage_uri: http://www.ohler.com/oj/
|
288
275
|
source_code_uri: https://github.com/ohler55/oj
|
289
276
|
wiki_uri: https://github.com/ohler55/oj/wiki
|
277
|
+
rubygems_mfa_required: 'true'
|
290
278
|
post_install_message:
|
291
279
|
rdoc_options:
|
292
280
|
- "--title"
|
@@ -299,113 +287,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
299
287
|
requirements:
|
300
288
|
- - ">="
|
301
289
|
- !ruby/object:Gem::Version
|
302
|
-
version: '2.
|
290
|
+
version: '2.7'
|
303
291
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
304
292
|
requirements:
|
305
293
|
- - ">="
|
306
294
|
- !ruby/object:Gem::Version
|
307
295
|
version: '0'
|
308
296
|
requirements: []
|
309
|
-
rubygems_version: 3.
|
297
|
+
rubygems_version: 3.4.1
|
310
298
|
signing_key:
|
311
299
|
specification_version: 4
|
312
300
|
summary: A fast JSON parser and serializer.
|
313
|
-
test_files:
|
314
|
-
- test/_test_active.rb
|
315
|
-
- test/_test_active_mimic.rb
|
316
|
-
- test/_test_mimic_rails.rb
|
317
|
-
- test/activerecord/result_test.rb
|
318
|
-
- test/activesupport4/decoding_test.rb
|
319
|
-
- test/activesupport4/encoding_test.rb
|
320
|
-
- test/activesupport4/test_helper.rb
|
321
|
-
- test/activesupport5/abstract_unit.rb
|
322
|
-
- test/activesupport5/decoding_test.rb
|
323
|
-
- test/activesupport5/encoding_test.rb
|
324
|
-
- test/activesupport5/encoding_test_cases.rb
|
325
|
-
- test/activesupport5/test_helper.rb
|
326
|
-
- test/activesupport5/time_zone_test_helpers.rb
|
327
|
-
- test/activesupport6/abstract_unit.rb
|
328
|
-
- test/activesupport6/decoding_test.rb
|
329
|
-
- test/activesupport6/encoding_test.rb
|
330
|
-
- test/activesupport6/encoding_test_cases.rb
|
331
|
-
- test/activesupport6/test_common.rb
|
332
|
-
- test/activesupport6/test_helper.rb
|
333
|
-
- test/activesupport6/time_zone_test_helpers.rb
|
334
|
-
- test/bar.rb
|
335
|
-
- test/baz.rb
|
336
|
-
- test/bug.rb
|
337
|
-
- test/files.rb
|
338
|
-
- test/foo.rb
|
339
|
-
- test/helper.rb
|
340
|
-
- test/isolated/shared.rb
|
341
|
-
- test/isolated/test_mimic_after.rb
|
342
|
-
- test/isolated/test_mimic_alone.rb
|
343
|
-
- test/isolated/test_mimic_as_json.rb
|
344
|
-
- test/isolated/test_mimic_before.rb
|
345
|
-
- test/isolated/test_mimic_define.rb
|
346
|
-
- test/isolated/test_mimic_rails_after.rb
|
347
|
-
- test/isolated/test_mimic_rails_before.rb
|
348
|
-
- test/isolated/test_mimic_redefine.rb
|
349
|
-
- test/json_gem/json_addition_test.rb
|
350
|
-
- test/json_gem/json_common_interface_test.rb
|
351
|
-
- test/json_gem/json_encoding_test.rb
|
352
|
-
- test/json_gem/json_ext_parser_test.rb
|
353
|
-
- test/json_gem/json_fixtures_test.rb
|
354
|
-
- test/json_gem/json_generator_test.rb
|
355
|
-
- test/json_gem/json_generic_object_test.rb
|
356
|
-
- test/json_gem/json_parser_test.rb
|
357
|
-
- test/json_gem/json_string_matching_test.rb
|
358
|
-
- test/json_gem/test_helper.rb
|
359
|
-
- test/mem.rb
|
360
|
-
- test/perf.rb
|
361
|
-
- test/perf_compat.rb
|
362
|
-
- test/perf_fast.rb
|
363
|
-
- test/perf_file.rb
|
364
|
-
- test/perf_object.rb
|
365
|
-
- test/perf_once.rb
|
366
|
-
- test/perf_parser.rb
|
367
|
-
- test/perf_saj.rb
|
368
|
-
- test/perf_scp.rb
|
369
|
-
- test/perf_simple.rb
|
370
|
-
- test/perf_strict.rb
|
371
|
-
- test/perf_wab.rb
|
372
|
-
- test/prec.rb
|
373
|
-
- test/sample/change.rb
|
374
|
-
- test/sample/dir.rb
|
375
|
-
- test/sample/doc.rb
|
376
|
-
- test/sample/file.rb
|
377
|
-
- test/sample/group.rb
|
378
|
-
- test/sample/hasprops.rb
|
379
|
-
- test/sample/layer.rb
|
380
|
-
- test/sample/line.rb
|
381
|
-
- test/sample/oval.rb
|
382
|
-
- test/sample/rect.rb
|
383
|
-
- test/sample/shape.rb
|
384
|
-
- test/sample/text.rb
|
385
|
-
- test/sample.rb
|
386
|
-
- test/sample_json.rb
|
387
|
-
- test/test_compat.rb
|
388
|
-
- test/test_custom.rb
|
389
|
-
- test/test_debian.rb
|
390
|
-
- test/test_fast.rb
|
391
|
-
- test/test_file.rb
|
392
|
-
- test/test_gc.rb
|
393
|
-
- test/test_generate.rb
|
394
|
-
- test/test_hash.rb
|
395
|
-
- test/test_integer_range.rb
|
396
|
-
- test/test_null.rb
|
397
|
-
- test/test_object.rb
|
398
|
-
- test/test_parser.rb
|
399
|
-
- test/test_parser_saj.rb
|
400
|
-
- test/test_parser_usual.rb
|
401
|
-
- test/test_rails.rb
|
402
|
-
- test/test_saj.rb
|
403
|
-
- test/test_scp.rb
|
404
|
-
- test/test_strict.rb
|
405
|
-
- test/test_various.rb
|
406
|
-
- test/test_wab.rb
|
407
|
-
- test/test_writer.rb
|
408
|
-
- test/tests.rb
|
409
|
-
- test/tests_mimic.rb
|
410
|
-
- test/tests_mimic_addition.rb
|
411
|
-
- test/zoo.rb
|
301
|
+
test_files: []
|
@@ -1,108 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'activesupport4/test_helper'
|
3
|
-
require 'active_support/json'
|
4
|
-
require 'active_support/time'
|
5
|
-
|
6
|
-
class TestJSONDecoding < ActiveSupport::TestCase
|
7
|
-
class Foo
|
8
|
-
def self.json_create(object)
|
9
|
-
"Foo"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
TESTS = {
|
14
|
-
%q({"returnTo":{"\/categories":"\/"}}) => {"returnTo" => {"/categories" => "/"}},
|
15
|
-
%q({"return\\"To\\":":{"\/categories":"\/"}}) => {"return\"To\":" => {"/categories" => "/"}},
|
16
|
-
%q({"returnTo":{"\/categories":1}}) => {"returnTo" => {"/categories" => 1}},
|
17
|
-
%({"returnTo":[1,"a"]}) => {"returnTo" => [1, "a"]},
|
18
|
-
%({"returnTo":[1,"\\"a\\",", "b"]}) => {"returnTo" => [1, "\"a\",", "b"]},
|
19
|
-
%({"a": "'", "b": "5,000"}) => {"a" => "'", "b" => "5,000"},
|
20
|
-
%({"a": "a's, b's and c's", "b": "5,000"}) => {"a" => "a's, b's and c's", "b" => "5,000"},
|
21
|
-
# multibyte
|
22
|
-
%({"matzue": "松江", "asakusa": "浅草"}) => {"matzue" => "松江", "asakusa" => "浅草"},
|
23
|
-
%({"a": "2007-01-01"}) => {'a' => Date.new(2007, 1, 1)},
|
24
|
-
%({"a": "2007-01-01 01:12:34 Z"}) => {'a' => Time.utc(2007, 1, 1, 1, 12, 34)},
|
25
|
-
%(["2007-01-01 01:12:34 Z"]) => [Time.utc(2007, 1, 1, 1, 12, 34)],
|
26
|
-
%(["2007-01-01 01:12:34 Z", "2007-01-01 01:12:35 Z"]) => [Time.utc(2007, 1, 1, 1, 12, 34), Time.utc(2007, 1, 1, 1, 12, 35)],
|
27
|
-
# no time zone
|
28
|
-
%({"a": "2007-01-01 01:12:34"}) => {'a' => "2007-01-01 01:12:34"},
|
29
|
-
# invalid date
|
30
|
-
%({"a": "1089-10-40"}) => {'a' => "1089-10-40"},
|
31
|
-
# xmlschema date notation
|
32
|
-
%({"a": "2009-08-10T19:01:02Z"}) => {'a' => Time.utc(2009, 8, 10, 19, 1, 2)},
|
33
|
-
%({"a": "2009-08-10T19:01:02+02:00"}) => {'a' => Time.utc(2009, 8, 10, 17, 1, 2)},
|
34
|
-
%({"a": "2009-08-10T19:01:02-05:00"}) => {'a' => Time.utc(2009, 8, 11, 00, 1, 2)},
|
35
|
-
# needs to be *exact*
|
36
|
-
%({"a": " 2007-01-01 01:12:34 Z "}) => {'a' => " 2007-01-01 01:12:34 Z "},
|
37
|
-
%({"a": "2007-01-01 : it's your birthday"}) => {'a' => "2007-01-01 : it's your birthday"},
|
38
|
-
%([]) => [],
|
39
|
-
%({}) => {},
|
40
|
-
%({"a":1}) => {"a" => 1},
|
41
|
-
%({"a": ""}) => {"a" => ""},
|
42
|
-
%({"a":"\\""}) => {"a" => "\""},
|
43
|
-
%({"a": null}) => {"a" => nil},
|
44
|
-
%({"a": true}) => {"a" => true},
|
45
|
-
%({"a": false}) => {"a" => false},
|
46
|
-
%q({"bad":"\\\\","trailing":""}) => {"bad" => "\\", "trailing" => ""},
|
47
|
-
%q({"a": "http:\/\/test.host\/posts\/1"}) => {"a" => "http://test.host/posts/1"},
|
48
|
-
%q({"a": "\u003cunicode\u0020escape\u003e"}) => {"a" => "<unicode escape>"},
|
49
|
-
%q({"a": "\\\\u0020skip double backslashes"}) => {"a" => "\\u0020skip double backslashes"},
|
50
|
-
%q({"a": "\u003cbr /\u003e"}) => {'a' => "<br />"},
|
51
|
-
%q({"b":["\u003ci\u003e","\u003cb\u003e","\u003cu\u003e"]}) => {'b' => ["<i>","<b>","<u>"]},
|
52
|
-
# test combination of dates and escaped or unicode encoded data in arrays
|
53
|
-
%q([{"d":"1970-01-01", "s":"\u0020escape"},{"d":"1970-01-01", "s":"\u0020escape"}]) =>
|
54
|
-
[{'d' => Date.new(1970, 1, 1), 's' => ' escape'},{'d' => Date.new(1970, 1, 1), 's' => ' escape'}],
|
55
|
-
%q([{"d":"1970-01-01","s":"http:\/\/example.com"},{"d":"1970-01-01","s":"http:\/\/example.com"}]) =>
|
56
|
-
[{'d' => Date.new(1970, 1, 1), 's' => 'http://example.com'},
|
57
|
-
{'d' => Date.new(1970, 1, 1), 's' => 'http://example.com'}],
|
58
|
-
# tests escaping of "\n" char with Yaml backend
|
59
|
-
%q({"a":"\n"}) => {"a"=>"\n"},
|
60
|
-
%q({"a":"\u000a"}) => {"a"=>"\n"},
|
61
|
-
%q({"a":"Line1\u000aLine2"}) => {"a"=>"Line1\nLine2"},
|
62
|
-
# prevent json unmarshalling
|
63
|
-
%q({"json_class":"TestJSONDecoding::Foo"}) => {"json_class"=>"TestJSONDecoding::Foo"},
|
64
|
-
# json "fragments" - these are invalid JSON, but ActionPack relies on this
|
65
|
-
%q("a string") => "a string",
|
66
|
-
%q(1.1) => 1.1,
|
67
|
-
%q(1) => 1,
|
68
|
-
%q(-1) => -1,
|
69
|
-
%q(true) => true,
|
70
|
-
%q(false) => false,
|
71
|
-
%q(null) => nil
|
72
|
-
}
|
73
|
-
|
74
|
-
TESTS.each_with_index do |(json, expected), index|
|
75
|
-
test "json decodes #{index}" do
|
76
|
-
prev = ActiveSupport.parse_json_times
|
77
|
-
ActiveSupport.parse_json_times = true
|
78
|
-
silence_warnings do
|
79
|
-
if expected.nil?
|
80
|
-
assert_nil ActiveSupport::JSON.decode(json), "JSON decoding failed for #{json}"
|
81
|
-
else
|
82
|
-
assert_equal expected, ActiveSupport::JSON.decode(json), "JSON decoding failed for #{json}"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
ActiveSupport.parse_json_times = prev
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
test "json decodes time json with time parsing disabled" do
|
90
|
-
prev = ActiveSupport.parse_json_times
|
91
|
-
ActiveSupport.parse_json_times = false
|
92
|
-
expected = {"a" => "2007-01-01 01:12:34 Z"}
|
93
|
-
assert_equal expected, ActiveSupport::JSON.decode(%({"a": "2007-01-01 01:12:34 Z"}))
|
94
|
-
ActiveSupport.parse_json_times = prev
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_failed_json_decoding
|
98
|
-
assert_raise(ActiveSupport::JSON.parse_error) { ActiveSupport::JSON.decode(%(undefined)) }
|
99
|
-
assert_raise(ActiveSupport::JSON.parse_error) { ActiveSupport::JSON.decode(%({a: 1})) }
|
100
|
-
assert_raise(ActiveSupport::JSON.parse_error) { ActiveSupport::JSON.decode(%({: 1})) }
|
101
|
-
assert_raise(ActiveSupport::JSON.parse_error) { ActiveSupport::JSON.decode(%()) }
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_cannot_pass_unsupported_options
|
105
|
-
assert_raise(ArgumentError) { ActiveSupport::JSON.decode("", create_additions: true) }
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|