json_pure 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -1
- data/README.md +2 -2
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/ext/json/ext/generator/generator.c +1 -0
- data/ext/json/ext/parser/parser.c +11 -8
- data/ext/json/ext/parser/parser.rl +3 -0
- data/java/src/json/ext/Parser.java +74 -71
- data/java/src/json/ext/Parser.rl +3 -0
- data/json.gemspec +0 -0
- data/json_pure.gemspec +4 -3
- data/lib/json/version.rb +1 -1
- data/tests/json_common_interface_test.rb +3 -3
- data/tests/json_parser_test.rb +19 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a00f1b6bc6dcfe1bb1f61cd43c013fa2ea8e8e35
|
4
|
+
data.tar.gz: 71abe50769b7736fbcec5051546c3a1df959c18e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd4501f58b7f348d7a9c3ec930dfc70739a329b66b6649ee3f688d2ea09a4ee6b27dab0807117ef586be80a483418acd1e93ad3b42d3954770405259832fe7d0
|
7
|
+
data.tar.gz: de4ab46ed538410857c7f4118147d6ee92348eb4dc6dbb85447c1142692a5dfefc6f01333565f909869ab249ea5043cf8c0debb851d7ff870602ab1900589d59
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## 2016-07-26 (2.0.2)
|
4
|
+
* Specify `required_ruby_version` for json\_pure.
|
5
|
+
* Fix issue #295 failure when parsing frozen strings.
|
6
|
+
|
3
7
|
## 2016-07-01 (2.0.1)
|
4
8
|
* Fix problem when requiring json\_pure and Parser constant was defiend top
|
5
9
|
level.
|
@@ -28,7 +32,7 @@
|
|
28
32
|
`JSON.dump_default_options`.
|
29
33
|
* More tests by Michael Mac-Vicar <mmacvicar@gmail.com> and fixing
|
30
34
|
`space_before` accessor in generator.
|
31
|
-
* Performance on Jruby
|
35
|
+
* Performance on Jruby improved by Ben Browning <bbrownin@redhat.com>.
|
32
36
|
* Some fixes to be compatible with the new Ruby 2.2 by Zachary Scott <e@zzak.io>
|
33
37
|
and SHIBATA Hiroshi <hsbt@ruby-lang.org>.
|
34
38
|
|
data/README.md
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
|
4
4
|
## Description
|
5
5
|
|
6
|
-
This is a implementation of the JSON specification according to RFC
|
7
|
-
http://www.ietf.org/rfc/
|
6
|
+
This is a implementation of the JSON specification according to RFC 7159
|
7
|
+
http://www.ietf.org/rfc/rfc7159.txt . Starting from version 1.0.0 on there
|
8
8
|
will be two variants available:
|
9
9
|
|
10
10
|
* A pure ruby variant, that relies on the iconv and the stringscan
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.2
|
@@ -1670,6 +1670,9 @@ static VALUE convert_encoding(VALUE source)
|
|
1670
1670
|
#ifdef HAVE_RUBY_ENCODING_H
|
1671
1671
|
rb_encoding *enc = rb_enc_get(source);
|
1672
1672
|
if (enc == rb_ascii8bit_encoding()) {
|
1673
|
+
if (OBJ_FROZEN(source)) {
|
1674
|
+
source = rb_str_dup(source);
|
1675
|
+
}
|
1673
1676
|
FORCE_UTF8(source);
|
1674
1677
|
} else {
|
1675
1678
|
source = rb_str_conv_enc(source, NULL, rb_utf8_encoding());
|
@@ -1805,7 +1808,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
|
1805
1808
|
}
|
1806
1809
|
|
1807
1810
|
|
1808
|
-
#line
|
1811
|
+
#line 1812 "parser.c"
|
1809
1812
|
enum {JSON_start = 1};
|
1810
1813
|
enum {JSON_first_final = 10};
|
1811
1814
|
enum {JSON_error = 0};
|
@@ -1813,7 +1816,7 @@ enum {JSON_error = 0};
|
|
1813
1816
|
enum {JSON_en_main = 1};
|
1814
1817
|
|
1815
1818
|
|
1816
|
-
#line
|
1819
|
+
#line 720 "parser.rl"
|
1817
1820
|
|
1818
1821
|
|
1819
1822
|
/*
|
@@ -1830,16 +1833,16 @@ static VALUE cParser_parse(VALUE self)
|
|
1830
1833
|
GET_PARSER;
|
1831
1834
|
|
1832
1835
|
|
1833
|
-
#line
|
1836
|
+
#line 1837 "parser.c"
|
1834
1837
|
{
|
1835
1838
|
cs = JSON_start;
|
1836
1839
|
}
|
1837
1840
|
|
1838
|
-
#line
|
1841
|
+
#line 736 "parser.rl"
|
1839
1842
|
p = json->source;
|
1840
1843
|
pe = p + json->len;
|
1841
1844
|
|
1842
|
-
#line
|
1845
|
+
#line 1846 "parser.c"
|
1843
1846
|
{
|
1844
1847
|
if ( p == pe )
|
1845
1848
|
goto _test_eof;
|
@@ -1873,7 +1876,7 @@ st0:
|
|
1873
1876
|
cs = 0;
|
1874
1877
|
goto _out;
|
1875
1878
|
tr2:
|
1876
|
-
#line
|
1879
|
+
#line 712 "parser.rl"
|
1877
1880
|
{
|
1878
1881
|
char *np = JSON_parse_value(json, p, pe, &result, 0);
|
1879
1882
|
if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
|
@@ -1883,7 +1886,7 @@ st10:
|
|
1883
1886
|
if ( ++p == pe )
|
1884
1887
|
goto _test_eof10;
|
1885
1888
|
case 10:
|
1886
|
-
#line
|
1889
|
+
#line 1890 "parser.c"
|
1887
1890
|
switch( (*p) ) {
|
1888
1891
|
case 13: goto st10;
|
1889
1892
|
case 32: goto st10;
|
@@ -1972,7 +1975,7 @@ case 9:
|
|
1972
1975
|
_out: {}
|
1973
1976
|
}
|
1974
1977
|
|
1975
|
-
#line
|
1978
|
+
#line 739 "parser.rl"
|
1976
1979
|
|
1977
1980
|
if (cs >= JSON_first_final && p == pe) {
|
1978
1981
|
return result;
|
@@ -565,6 +565,9 @@ static VALUE convert_encoding(VALUE source)
|
|
565
565
|
#ifdef HAVE_RUBY_ENCODING_H
|
566
566
|
rb_encoding *enc = rb_enc_get(source);
|
567
567
|
if (enc == rb_ascii8bit_encoding()) {
|
568
|
+
if (OBJ_FROZEN(source)) {
|
569
|
+
source = rb_str_dup(source);
|
570
|
+
}
|
568
571
|
FORCE_UTF8(source);
|
569
572
|
} else {
|
570
573
|
source = rb_str_conv_enc(source, NULL, rb_utf8_encoding());
|
@@ -181,6 +181,9 @@ public class Parser extends RubyObject {
|
|
181
181
|
private RubyString convertEncoding(ThreadContext context, RubyString source) {
|
182
182
|
RubyEncoding encoding = (RubyEncoding)source.encoding(context);
|
183
183
|
if (encoding == info.ascii8bit.get()) {
|
184
|
+
if (source.isFrozen()) {
|
185
|
+
source = (RubyString) source.dup();
|
186
|
+
}
|
184
187
|
source.force_encoding(context, info.utf8.get());
|
185
188
|
} else {
|
186
189
|
source = (RubyString) source.encode(context, info.utf8.get());
|
@@ -304,11 +307,11 @@ public class Parser extends RubyObject {
|
|
304
307
|
}
|
305
308
|
|
306
309
|
|
307
|
-
// line
|
310
|
+
// line 333 "Parser.rl"
|
308
311
|
|
309
312
|
|
310
313
|
|
311
|
-
// line
|
314
|
+
// line 315 "Parser.java"
|
312
315
|
private static byte[] init__JSON_value_actions_0()
|
313
316
|
{
|
314
317
|
return new byte [] {
|
@@ -422,7 +425,7 @@ static final int JSON_value_error = 0;
|
|
422
425
|
static final int JSON_value_en_main = 1;
|
423
426
|
|
424
427
|
|
425
|
-
// line
|
428
|
+
// line 439 "Parser.rl"
|
426
429
|
|
427
430
|
|
428
431
|
void parseValue(ParserResult res, int p, int pe) {
|
@@ -430,14 +433,14 @@ static final int JSON_value_en_main = 1;
|
|
430
433
|
IRubyObject result = null;
|
431
434
|
|
432
435
|
|
433
|
-
// line
|
436
|
+
// line 437 "Parser.java"
|
434
437
|
{
|
435
438
|
cs = JSON_value_start;
|
436
439
|
}
|
437
440
|
|
438
|
-
// line
|
441
|
+
// line 446 "Parser.rl"
|
439
442
|
|
440
|
-
// line
|
443
|
+
// line 444 "Parser.java"
|
441
444
|
{
|
442
445
|
int _klen;
|
443
446
|
int _trans = 0;
|
@@ -463,13 +466,13 @@ case 1:
|
|
463
466
|
while ( _nacts-- > 0 ) {
|
464
467
|
switch ( _JSON_value_actions[_acts++] ) {
|
465
468
|
case 9:
|
466
|
-
// line
|
469
|
+
// line 424 "Parser.rl"
|
467
470
|
{
|
468
471
|
p--;
|
469
472
|
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
470
473
|
}
|
471
474
|
break;
|
472
|
-
// line
|
475
|
+
// line 476 "Parser.java"
|
473
476
|
}
|
474
477
|
}
|
475
478
|
|
@@ -532,25 +535,25 @@ case 1:
|
|
532
535
|
switch ( _JSON_value_actions[_acts++] )
|
533
536
|
{
|
534
537
|
case 0:
|
535
|
-
// line
|
538
|
+
// line 341 "Parser.rl"
|
536
539
|
{
|
537
540
|
result = getRuntime().getNil();
|
538
541
|
}
|
539
542
|
break;
|
540
543
|
case 1:
|
541
|
-
// line
|
544
|
+
// line 344 "Parser.rl"
|
542
545
|
{
|
543
546
|
result = getRuntime().getFalse();
|
544
547
|
}
|
545
548
|
break;
|
546
549
|
case 2:
|
547
|
-
// line
|
550
|
+
// line 347 "Parser.rl"
|
548
551
|
{
|
549
552
|
result = getRuntime().getTrue();
|
550
553
|
}
|
551
554
|
break;
|
552
555
|
case 3:
|
553
|
-
// line
|
556
|
+
// line 350 "Parser.rl"
|
554
557
|
{
|
555
558
|
if (parser.allowNaN) {
|
556
559
|
result = getConstant(CONST_NAN);
|
@@ -560,7 +563,7 @@ case 1:
|
|
560
563
|
}
|
561
564
|
break;
|
562
565
|
case 4:
|
563
|
-
// line
|
566
|
+
// line 357 "Parser.rl"
|
564
567
|
{
|
565
568
|
if (parser.allowNaN) {
|
566
569
|
result = getConstant(CONST_INFINITY);
|
@@ -570,7 +573,7 @@ case 1:
|
|
570
573
|
}
|
571
574
|
break;
|
572
575
|
case 5:
|
573
|
-
// line
|
576
|
+
// line 364 "Parser.rl"
|
574
577
|
{
|
575
578
|
if (pe > p + 8 &&
|
576
579
|
absSubSequence(p, p + 9).equals(JSON_MINUS_INFINITY)) {
|
@@ -599,7 +602,7 @@ case 1:
|
|
599
602
|
}
|
600
603
|
break;
|
601
604
|
case 6:
|
602
|
-
// line
|
605
|
+
// line 390 "Parser.rl"
|
603
606
|
{
|
604
607
|
parseString(res, p, pe);
|
605
608
|
if (res.result == null) {
|
@@ -612,7 +615,7 @@ case 1:
|
|
612
615
|
}
|
613
616
|
break;
|
614
617
|
case 7:
|
615
|
-
// line
|
618
|
+
// line 400 "Parser.rl"
|
616
619
|
{
|
617
620
|
currentNesting++;
|
618
621
|
parseArray(res, p, pe);
|
@@ -627,7 +630,7 @@ case 1:
|
|
627
630
|
}
|
628
631
|
break;
|
629
632
|
case 8:
|
630
|
-
// line
|
633
|
+
// line 412 "Parser.rl"
|
631
634
|
{
|
632
635
|
currentNesting++;
|
633
636
|
parseObject(res, p, pe);
|
@@ -641,7 +644,7 @@ case 1:
|
|
641
644
|
}
|
642
645
|
}
|
643
646
|
break;
|
644
|
-
// line
|
647
|
+
// line 648 "Parser.java"
|
645
648
|
}
|
646
649
|
}
|
647
650
|
}
|
@@ -661,7 +664,7 @@ case 5:
|
|
661
664
|
break; }
|
662
665
|
}
|
663
666
|
|
664
|
-
// line
|
667
|
+
// line 447 "Parser.rl"
|
665
668
|
|
666
669
|
if (cs >= JSON_value_first_final && result != null) {
|
667
670
|
res.update(result, p);
|
@@ -671,7 +674,7 @@ case 5:
|
|
671
674
|
}
|
672
675
|
|
673
676
|
|
674
|
-
// line
|
677
|
+
// line 678 "Parser.java"
|
675
678
|
private static byte[] init__JSON_integer_actions_0()
|
676
679
|
{
|
677
680
|
return new byte [] {
|
@@ -770,7 +773,7 @@ static final int JSON_integer_error = 0;
|
|
770
773
|
static final int JSON_integer_en_main = 1;
|
771
774
|
|
772
775
|
|
773
|
-
// line
|
776
|
+
// line 466 "Parser.rl"
|
774
777
|
|
775
778
|
|
776
779
|
void parseInteger(ParserResult res, int p, int pe) {
|
@@ -788,15 +791,15 @@ static final int JSON_integer_en_main = 1;
|
|
788
791
|
int cs = EVIL;
|
789
792
|
|
790
793
|
|
791
|
-
// line
|
794
|
+
// line 795 "Parser.java"
|
792
795
|
{
|
793
796
|
cs = JSON_integer_start;
|
794
797
|
}
|
795
798
|
|
796
|
-
// line
|
799
|
+
// line 483 "Parser.rl"
|
797
800
|
int memo = p;
|
798
801
|
|
799
|
-
// line
|
802
|
+
// line 803 "Parser.java"
|
800
803
|
{
|
801
804
|
int _klen;
|
802
805
|
int _trans = 0;
|
@@ -877,13 +880,13 @@ case 1:
|
|
877
880
|
switch ( _JSON_integer_actions[_acts++] )
|
878
881
|
{
|
879
882
|
case 0:
|
880
|
-
// line
|
883
|
+
// line 460 "Parser.rl"
|
881
884
|
{
|
882
885
|
p--;
|
883
886
|
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
884
887
|
}
|
885
888
|
break;
|
886
|
-
// line
|
889
|
+
// line 890 "Parser.java"
|
887
890
|
}
|
888
891
|
}
|
889
892
|
}
|
@@ -903,7 +906,7 @@ case 5:
|
|
903
906
|
break; }
|
904
907
|
}
|
905
908
|
|
906
|
-
// line
|
909
|
+
// line 485 "Parser.rl"
|
907
910
|
|
908
911
|
if (cs < JSON_integer_first_final) {
|
909
912
|
return -1;
|
@@ -925,7 +928,7 @@ case 5:
|
|
925
928
|
}
|
926
929
|
|
927
930
|
|
928
|
-
// line
|
931
|
+
// line 932 "Parser.java"
|
929
932
|
private static byte[] init__JSON_float_actions_0()
|
930
933
|
{
|
931
934
|
return new byte [] {
|
@@ -1027,7 +1030,7 @@ static final int JSON_float_error = 0;
|
|
1027
1030
|
static final int JSON_float_en_main = 1;
|
1028
1031
|
|
1029
1032
|
|
1030
|
-
// line
|
1033
|
+
// line 520 "Parser.rl"
|
1031
1034
|
|
1032
1035
|
|
1033
1036
|
void parseFloat(ParserResult res, int p, int pe) {
|
@@ -1045,15 +1048,15 @@ static final int JSON_float_en_main = 1;
|
|
1045
1048
|
int cs = EVIL;
|
1046
1049
|
|
1047
1050
|
|
1048
|
-
// line
|
1051
|
+
// line 1052 "Parser.java"
|
1049
1052
|
{
|
1050
1053
|
cs = JSON_float_start;
|
1051
1054
|
}
|
1052
1055
|
|
1053
|
-
// line
|
1056
|
+
// line 537 "Parser.rl"
|
1054
1057
|
int memo = p;
|
1055
1058
|
|
1056
|
-
// line
|
1059
|
+
// line 1060 "Parser.java"
|
1057
1060
|
{
|
1058
1061
|
int _klen;
|
1059
1062
|
int _trans = 0;
|
@@ -1134,13 +1137,13 @@ case 1:
|
|
1134
1137
|
switch ( _JSON_float_actions[_acts++] )
|
1135
1138
|
{
|
1136
1139
|
case 0:
|
1137
|
-
// line
|
1140
|
+
// line 511 "Parser.rl"
|
1138
1141
|
{
|
1139
1142
|
p--;
|
1140
1143
|
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
1141
1144
|
}
|
1142
1145
|
break;
|
1143
|
-
// line
|
1146
|
+
// line 1147 "Parser.java"
|
1144
1147
|
}
|
1145
1148
|
}
|
1146
1149
|
}
|
@@ -1160,7 +1163,7 @@ case 5:
|
|
1160
1163
|
break; }
|
1161
1164
|
}
|
1162
1165
|
|
1163
|
-
// line
|
1166
|
+
// line 539 "Parser.rl"
|
1164
1167
|
|
1165
1168
|
if (cs < JSON_float_first_final) {
|
1166
1169
|
return -1;
|
@@ -1176,7 +1179,7 @@ case 5:
|
|
1176
1179
|
}
|
1177
1180
|
|
1178
1181
|
|
1179
|
-
// line
|
1182
|
+
// line 1183 "Parser.java"
|
1180
1183
|
private static byte[] init__JSON_string_actions_0()
|
1181
1184
|
{
|
1182
1185
|
return new byte [] {
|
@@ -1278,7 +1281,7 @@ static final int JSON_string_error = 0;
|
|
1278
1281
|
static final int JSON_string_en_main = 1;
|
1279
1282
|
|
1280
1283
|
|
1281
|
-
// line
|
1284
|
+
// line 584 "Parser.rl"
|
1282
1285
|
|
1283
1286
|
|
1284
1287
|
void parseString(ParserResult res, int p, int pe) {
|
@@ -1286,15 +1289,15 @@ static final int JSON_string_en_main = 1;
|
|
1286
1289
|
IRubyObject result = null;
|
1287
1290
|
|
1288
1291
|
|
1289
|
-
// line
|
1292
|
+
// line 1293 "Parser.java"
|
1290
1293
|
{
|
1291
1294
|
cs = JSON_string_start;
|
1292
1295
|
}
|
1293
1296
|
|
1294
|
-
// line
|
1297
|
+
// line 591 "Parser.rl"
|
1295
1298
|
int memo = p;
|
1296
1299
|
|
1297
|
-
// line
|
1300
|
+
// line 1301 "Parser.java"
|
1298
1301
|
{
|
1299
1302
|
int _klen;
|
1300
1303
|
int _trans = 0;
|
@@ -1375,7 +1378,7 @@ case 1:
|
|
1375
1378
|
switch ( _JSON_string_actions[_acts++] )
|
1376
1379
|
{
|
1377
1380
|
case 0:
|
1378
|
-
// line
|
1381
|
+
// line 559 "Parser.rl"
|
1379
1382
|
{
|
1380
1383
|
int offset = byteList.begin();
|
1381
1384
|
ByteList decoded = decoder.decode(byteList, memo + 1 - offset,
|
@@ -1390,13 +1393,13 @@ case 1:
|
|
1390
1393
|
}
|
1391
1394
|
break;
|
1392
1395
|
case 1:
|
1393
|
-
// line
|
1396
|
+
// line 572 "Parser.rl"
|
1394
1397
|
{
|
1395
1398
|
p--;
|
1396
1399
|
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
1397
1400
|
}
|
1398
1401
|
break;
|
1399
|
-
// line
|
1402
|
+
// line 1403 "Parser.java"
|
1400
1403
|
}
|
1401
1404
|
}
|
1402
1405
|
}
|
@@ -1416,7 +1419,7 @@ case 5:
|
|
1416
1419
|
break; }
|
1417
1420
|
}
|
1418
1421
|
|
1419
|
-
// line
|
1422
|
+
// line 593 "Parser.rl"
|
1420
1423
|
|
1421
1424
|
if (parser.createAdditions) {
|
1422
1425
|
RubyHash matchString = parser.matchString;
|
@@ -1454,7 +1457,7 @@ case 5:
|
|
1454
1457
|
}
|
1455
1458
|
|
1456
1459
|
|
1457
|
-
// line
|
1460
|
+
// line 1461 "Parser.java"
|
1458
1461
|
private static byte[] init__JSON_array_actions_0()
|
1459
1462
|
{
|
1460
1463
|
return new byte [] {
|
@@ -1567,7 +1570,7 @@ static final int JSON_array_error = 0;
|
|
1567
1570
|
static final int JSON_array_en_main = 1;
|
1568
1571
|
|
1569
1572
|
|
1570
|
-
// line
|
1573
|
+
// line 666 "Parser.rl"
|
1571
1574
|
|
1572
1575
|
|
1573
1576
|
void parseArray(ParserResult res, int p, int pe) {
|
@@ -1587,14 +1590,14 @@ static final int JSON_array_en_main = 1;
|
|
1587
1590
|
}
|
1588
1591
|
|
1589
1592
|
|
1590
|
-
// line
|
1593
|
+
// line 1594 "Parser.java"
|
1591
1594
|
{
|
1592
1595
|
cs = JSON_array_start;
|
1593
1596
|
}
|
1594
1597
|
|
1595
|
-
// line
|
1598
|
+
// line 685 "Parser.rl"
|
1596
1599
|
|
1597
|
-
// line
|
1600
|
+
// line 1601 "Parser.java"
|
1598
1601
|
{
|
1599
1602
|
int _klen;
|
1600
1603
|
int _trans = 0;
|
@@ -1675,7 +1678,7 @@ case 1:
|
|
1675
1678
|
switch ( _JSON_array_actions[_acts++] )
|
1676
1679
|
{
|
1677
1680
|
case 0:
|
1678
|
-
// line
|
1681
|
+
// line 635 "Parser.rl"
|
1679
1682
|
{
|
1680
1683
|
parseValue(res, p, pe);
|
1681
1684
|
if (res.result == null) {
|
@@ -1692,13 +1695,13 @@ case 1:
|
|
1692
1695
|
}
|
1693
1696
|
break;
|
1694
1697
|
case 1:
|
1695
|
-
// line
|
1698
|
+
// line 650 "Parser.rl"
|
1696
1699
|
{
|
1697
1700
|
p--;
|
1698
1701
|
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
1699
1702
|
}
|
1700
1703
|
break;
|
1701
|
-
// line
|
1704
|
+
// line 1705 "Parser.java"
|
1702
1705
|
}
|
1703
1706
|
}
|
1704
1707
|
}
|
@@ -1718,7 +1721,7 @@ case 5:
|
|
1718
1721
|
break; }
|
1719
1722
|
}
|
1720
1723
|
|
1721
|
-
// line
|
1724
|
+
// line 686 "Parser.rl"
|
1722
1725
|
|
1723
1726
|
if (cs >= JSON_array_first_final) {
|
1724
1727
|
res.update(result, p + 1);
|
@@ -1728,7 +1731,7 @@ case 5:
|
|
1728
1731
|
}
|
1729
1732
|
|
1730
1733
|
|
1731
|
-
// line
|
1734
|
+
// line 1735 "Parser.java"
|
1732
1735
|
private static byte[] init__JSON_object_actions_0()
|
1733
1736
|
{
|
1734
1737
|
return new byte [] {
|
@@ -1851,7 +1854,7 @@ static final int JSON_object_error = 0;
|
|
1851
1854
|
static final int JSON_object_en_main = 1;
|
1852
1855
|
|
1853
1856
|
|
1854
|
-
// line
|
1857
|
+
// line 745 "Parser.rl"
|
1855
1858
|
|
1856
1859
|
|
1857
1860
|
void parseObject(ParserResult res, int p, int pe) {
|
@@ -1876,14 +1879,14 @@ static final int JSON_object_en_main = 1;
|
|
1876
1879
|
}
|
1877
1880
|
|
1878
1881
|
|
1879
|
-
// line
|
1882
|
+
// line 1883 "Parser.java"
|
1880
1883
|
{
|
1881
1884
|
cs = JSON_object_start;
|
1882
1885
|
}
|
1883
1886
|
|
1884
|
-
// line
|
1887
|
+
// line 769 "Parser.rl"
|
1885
1888
|
|
1886
|
-
// line
|
1889
|
+
// line 1890 "Parser.java"
|
1887
1890
|
{
|
1888
1891
|
int _klen;
|
1889
1892
|
int _trans = 0;
|
@@ -1964,7 +1967,7 @@ case 1:
|
|
1964
1967
|
switch ( _JSON_object_actions[_acts++] )
|
1965
1968
|
{
|
1966
1969
|
case 0:
|
1967
|
-
// line
|
1970
|
+
// line 700 "Parser.rl"
|
1968
1971
|
{
|
1969
1972
|
parseValue(res, p, pe);
|
1970
1973
|
if (res.result == null) {
|
@@ -1981,7 +1984,7 @@ case 1:
|
|
1981
1984
|
}
|
1982
1985
|
break;
|
1983
1986
|
case 1:
|
1984
|
-
// line
|
1987
|
+
// line 715 "Parser.rl"
|
1985
1988
|
{
|
1986
1989
|
parseString(res, p, pe);
|
1987
1990
|
if (res.result == null) {
|
@@ -2001,13 +2004,13 @@ case 1:
|
|
2001
2004
|
}
|
2002
2005
|
break;
|
2003
2006
|
case 2:
|
2004
|
-
// line
|
2007
|
+
// line 733 "Parser.rl"
|
2005
2008
|
{
|
2006
2009
|
p--;
|
2007
2010
|
{ p += 1; _goto_targ = 5; if (true) continue _goto;}
|
2008
2011
|
}
|
2009
2012
|
break;
|
2010
|
-
// line
|
2013
|
+
// line 2014 "Parser.java"
|
2011
2014
|
}
|
2012
2015
|
}
|
2013
2016
|
}
|
@@ -2027,7 +2030,7 @@ case 5:
|
|
2027
2030
|
break; }
|
2028
2031
|
}
|
2029
2032
|
|
2030
|
-
// line
|
2033
|
+
// line 770 "Parser.rl"
|
2031
2034
|
|
2032
2035
|
if (cs < JSON_object_first_final) {
|
2033
2036
|
res.update(null, p + 1);
|
@@ -2060,7 +2063,7 @@ case 5:
|
|
2060
2063
|
}
|
2061
2064
|
|
2062
2065
|
|
2063
|
-
// line
|
2066
|
+
// line 2067 "Parser.java"
|
2064
2067
|
private static byte[] init__JSON_actions_0()
|
2065
2068
|
{
|
2066
2069
|
return new byte [] {
|
@@ -2163,7 +2166,7 @@ static final int JSON_error = 0;
|
|
2163
2166
|
static final int JSON_en_main = 1;
|
2164
2167
|
|
2165
2168
|
|
2166
|
-
// line
|
2169
|
+
// line 821 "Parser.rl"
|
2167
2170
|
|
2168
2171
|
|
2169
2172
|
public IRubyObject parseImplemetation() {
|
@@ -2173,16 +2176,16 @@ static final int JSON_en_main = 1;
|
|
2173
2176
|
ParserResult res = new ParserResult();
|
2174
2177
|
|
2175
2178
|
|
2176
|
-
// line
|
2179
|
+
// line 2180 "Parser.java"
|
2177
2180
|
{
|
2178
2181
|
cs = JSON_start;
|
2179
2182
|
}
|
2180
2183
|
|
2181
|
-
// line
|
2184
|
+
// line 830 "Parser.rl"
|
2182
2185
|
p = byteList.begin();
|
2183
2186
|
pe = p + byteList.length();
|
2184
2187
|
|
2185
|
-
// line
|
2188
|
+
// line 2189 "Parser.java"
|
2186
2189
|
{
|
2187
2190
|
int _klen;
|
2188
2191
|
int _trans = 0;
|
@@ -2263,7 +2266,7 @@ case 1:
|
|
2263
2266
|
switch ( _JSON_actions[_acts++] )
|
2264
2267
|
{
|
2265
2268
|
case 0:
|
2266
|
-
// line
|
2269
|
+
// line 807 "Parser.rl"
|
2267
2270
|
{
|
2268
2271
|
parseValue(res, p, pe);
|
2269
2272
|
if (res.result == null) {
|
@@ -2275,7 +2278,7 @@ case 1:
|
|
2275
2278
|
}
|
2276
2279
|
}
|
2277
2280
|
break;
|
2278
|
-
// line
|
2281
|
+
// line 2282 "Parser.java"
|
2279
2282
|
}
|
2280
2283
|
}
|
2281
2284
|
}
|
@@ -2295,7 +2298,7 @@ case 5:
|
|
2295
2298
|
break; }
|
2296
2299
|
}
|
2297
2300
|
|
2298
|
-
// line
|
2301
|
+
// line 833 "Parser.rl"
|
2299
2302
|
|
2300
2303
|
if (cs >= JSON_first_final && p == pe) {
|
2301
2304
|
return result;
|
data/java/src/json/ext/Parser.rl
CHANGED
@@ -179,6 +179,9 @@ public class Parser extends RubyObject {
|
|
179
179
|
private RubyString convertEncoding(ThreadContext context, RubyString source) {
|
180
180
|
RubyEncoding encoding = (RubyEncoding)source.encoding(context);
|
181
181
|
if (encoding == info.ascii8bit.get()) {
|
182
|
+
if (source.isFrozen()) {
|
183
|
+
source = (RubyString) source.dup();
|
184
|
+
}
|
182
185
|
source.force_encoding(context, info.utf8.get());
|
183
186
|
} else {
|
184
187
|
source = (RubyString) source.encode(context, info.utf8.get());
|
data/json.gemspec
CHANGED
Binary file
|
data/json_pure.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: json_pure 2.0.
|
2
|
+
# stub: json_pure 2.0.2 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "json_pure".freeze
|
6
|
-
s.version = "2.0.
|
6
|
+
s.version = "2.0.2"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Florian Frank".freeze]
|
11
|
-
s.date = "2016-07-
|
11
|
+
s.date = "2016-07-26"
|
12
12
|
s.description = "This is a JSON implementation in pure Ruby.".freeze
|
13
13
|
s.email = "flori@ping.de".freeze
|
14
14
|
s.extra_rdoc_files = ["README.md".freeze]
|
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.homepage = "http://flori.github.com/json".freeze
|
17
17
|
s.licenses = ["Ruby".freeze]
|
18
18
|
s.rdoc_options = ["--title".freeze, "JSON implemention for ruby".freeze, "--main".freeze, "README.md".freeze]
|
19
|
+
s.required_ruby_version = Gem::Requirement.new("~> 2.0".freeze)
|
19
20
|
s.rubygems_version = "2.6.4".freeze
|
20
21
|
s.summary = "JSON Implementation for Ruby".freeze
|
21
22
|
s.test_files = ["./tests/test_helper.rb".freeze]
|
data/lib/json/version.rb
CHANGED
@@ -47,7 +47,7 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_deep_const_get
|
50
|
-
|
50
|
+
assert_raise(ArgumentError) { JSON.deep_const_get('Nix::Da') }
|
51
51
|
assert_equal File::SEPARATOR, JSON.deep_const_get('File::SEPARATOR')
|
52
52
|
end
|
53
53
|
|
@@ -93,8 +93,8 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase
|
|
93
93
|
|
94
94
|
def test_load_null
|
95
95
|
assert_equal nil, JSON.load(nil, nil, :allow_blank => true)
|
96
|
-
|
97
|
-
|
96
|
+
assert_raise(TypeError) { JSON.load(nil, nil, :allow_blank => false) }
|
97
|
+
assert_raise(JSON::ParserError) { JSON.load('', nil, :allow_blank => false) }
|
98
98
|
end
|
99
99
|
|
100
100
|
def test_dump
|
data/tests/json_parser_test.rb
CHANGED
@@ -40,6 +40,18 @@ class JSONParserTest < Test::Unit::TestCase
|
|
40
40
|
assert_equal({ 'a' => 'b' }, parser.parse)
|
41
41
|
end
|
42
42
|
|
43
|
+
def test_parse_values
|
44
|
+
assert_equal(nil, parse('null'))
|
45
|
+
assert_equal(false, parse('false'))
|
46
|
+
assert_equal(true, parse('true'))
|
47
|
+
assert_equal(-23, parse('-23'))
|
48
|
+
assert_equal(23, parse('23'))
|
49
|
+
assert_in_delta(0.23, parse('0.23'), 1e-2)
|
50
|
+
assert_in_delta(0.0, parse('0e0'), 1e-2)
|
51
|
+
assert_equal("", parse('""'))
|
52
|
+
assert_equal("foobar", parse('"foobar"'))
|
53
|
+
end
|
54
|
+
|
43
55
|
def test_parse_simple_arrays
|
44
56
|
assert_equal([], parse('[]'))
|
45
57
|
assert_equal([], parse(' [ ] '))
|
@@ -277,7 +289,6 @@ EOT
|
|
277
289
|
assert_equal data, parse(json)
|
278
290
|
end
|
279
291
|
|
280
|
-
|
281
292
|
class SubArray < Array
|
282
293
|
def <<(v)
|
283
294
|
@shifted = true
|
@@ -438,6 +449,13 @@ EOT
|
|
438
449
|
assert_equal obj, obj_again
|
439
450
|
end
|
440
451
|
|
452
|
+
def test_parsing_frozen_ascii8bit_string
|
453
|
+
assert_equal(
|
454
|
+
{ 'foo' => 'bar' },
|
455
|
+
JSON('{ "foo": "bar" }'.force_encoding(Encoding::ASCII_8BIT).freeze)
|
456
|
+
)
|
457
|
+
end
|
458
|
+
|
441
459
|
private
|
442
460
|
|
443
461
|
def assert_equal_float(expected, actual, delta = 1e-2)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_pure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -167,9 +167,9 @@ require_paths:
|
|
167
167
|
- lib
|
168
168
|
required_ruby_version: !ruby/object:Gem::Requirement
|
169
169
|
requirements:
|
170
|
-
- - "
|
170
|
+
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
|
-
version: '0'
|
172
|
+
version: '2.0'
|
173
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
174
|
requirements:
|
175
175
|
- - ">="
|