json 2.8.1 → 2.8.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 +4 -0
- data/ext/json/ext/parser/parser.c +148 -209
- data/ext/json/ext/parser/parser.rl +18 -24
- data/lib/json/common.rb +6 -5
- data/lib/json/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61a5759c78160e412505a53cc6579e3259689fe69adbd74d5e4aefb21b7ef64c
|
4
|
+
data.tar.gz: 072f37b6964a498df827e85e2038e4692c8452d5365a6c8794536508b1a95e9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e65781ec7eb7ab0c5b48b12eaf8e988fd5632874d60c6c35450ba934c586ceb47b622adb5b6f2652dcd7a1641dedbb0a674d1b458839d45944c862671d74d33f
|
7
|
+
data.tar.gz: 19b1ccd3cdf1126ac3825993a3c4aa06eff96b5ab80e0391ee3a150c4dd164d53052fa89aea0aeabd53e1bfbf4f513fc5276471c7eff1231e38f1ad89f1df1d7
|
data/CHANGES.md
CHANGED
@@ -394,6 +394,7 @@ typedef struct JSON_ParserStruct {
|
|
394
394
|
VALUE decimal_class;
|
395
395
|
VALUE match_string;
|
396
396
|
FBuffer fbuffer;
|
397
|
+
int in_array;
|
397
398
|
int max_nesting;
|
398
399
|
bool allow_nan;
|
399
400
|
bool allow_trailing_comma;
|
@@ -422,8 +423,7 @@ static const rb_data_type_t JSON_Parser_type;
|
|
422
423
|
static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
423
424
|
static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
|
424
425
|
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
|
425
|
-
static char *
|
426
|
-
static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
426
|
+
static char *JSON_parse_number(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
427
427
|
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
|
428
428
|
|
429
429
|
|
@@ -1077,7 +1077,7 @@ enum {JSON_value_error = 0};
|
|
1077
1077
|
enum {JSON_value_en_main = 1};
|
1078
1078
|
|
1079
1079
|
|
1080
|
-
#line
|
1080
|
+
#line 664 "parser.rl"
|
1081
1081
|
|
1082
1082
|
|
1083
1083
|
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
|
@@ -1090,7 +1090,7 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
1090
1090
|
cs = JSON_value_start;
|
1091
1091
|
}
|
1092
1092
|
|
1093
|
-
#line
|
1093
|
+
#line 671 "parser.rl"
|
1094
1094
|
|
1095
1095
|
#line 1096 "parser.c"
|
1096
1096
|
{
|
@@ -1150,11 +1150,7 @@ tr3:
|
|
1150
1150
|
raise_parse_error("unexpected token at '%s'", p);
|
1151
1151
|
}
|
1152
1152
|
}
|
1153
|
-
np =
|
1154
|
-
if (np != NULL) {
|
1155
|
-
{p = (( np))-1;}
|
1156
|
-
}
|
1157
|
-
np = JSON_parse_integer(json, p, pe, result);
|
1153
|
+
np = JSON_parse_number(json, p, pe, result);
|
1158
1154
|
if (np != NULL) {
|
1159
1155
|
{p = (( np))-1;}
|
1160
1156
|
}
|
@@ -1162,15 +1158,17 @@ tr3:
|
|
1162
1158
|
}
|
1163
1159
|
goto st29;
|
1164
1160
|
tr7:
|
1165
|
-
#line
|
1161
|
+
#line 637 "parser.rl"
|
1166
1162
|
{
|
1167
1163
|
char *np;
|
1164
|
+
json->in_array++;
|
1168
1165
|
np = JSON_parse_array(json, p, pe, result, current_nesting + 1);
|
1166
|
+
json->in_array--;
|
1169
1167
|
if (np == NULL) { p--; {p++; cs = 29; goto _out;} } else {p = (( np))-1;}
|
1170
1168
|
}
|
1171
1169
|
goto st29;
|
1172
1170
|
tr11:
|
1173
|
-
#line
|
1171
|
+
#line 645 "parser.rl"
|
1174
1172
|
{
|
1175
1173
|
char *np;
|
1176
1174
|
np = JSON_parse_object(json, p, pe, result, current_nesting + 1);
|
@@ -1219,9 +1217,9 @@ st29:
|
|
1219
1217
|
if ( ++p == pe )
|
1220
1218
|
goto _test_eof29;
|
1221
1219
|
case 29:
|
1222
|
-
#line
|
1220
|
+
#line 651 "parser.rl"
|
1223
1221
|
{ p--; {p++; cs = 29; goto _out;} }
|
1224
|
-
#line
|
1222
|
+
#line 1223 "parser.c"
|
1225
1223
|
switch( (*p) ) {
|
1226
1224
|
case 13: goto st29;
|
1227
1225
|
case 32: goto st29;
|
@@ -1462,7 +1460,7 @@ case 28:
|
|
1462
1460
|
_out: {}
|
1463
1461
|
}
|
1464
1462
|
|
1465
|
-
#line
|
1463
|
+
#line 672 "parser.rl"
|
1466
1464
|
|
1467
1465
|
if (json->freeze) {
|
1468
1466
|
OBJ_FREEZE(*result);
|
@@ -1477,7 +1475,7 @@ case 28:
|
|
1477
1475
|
}
|
1478
1476
|
|
1479
1477
|
|
1480
|
-
#line
|
1478
|
+
#line 1479 "parser.c"
|
1481
1479
|
enum {JSON_integer_start = 1};
|
1482
1480
|
enum {JSON_integer_first_final = 3};
|
1483
1481
|
enum {JSON_integer_error = 0};
|
@@ -1485,7 +1483,7 @@ enum {JSON_integer_error = 0};
|
|
1485
1483
|
enum {JSON_integer_en_main = 1};
|
1486
1484
|
|
1487
1485
|
|
1488
|
-
#line
|
1486
|
+
#line 693 "parser.rl"
|
1489
1487
|
|
1490
1488
|
|
1491
1489
|
#define MAX_FAST_INTEGER_SIZE 18
|
@@ -1510,82 +1508,8 @@ static inline VALUE fast_parse_integer(char *p, char *pe)
|
|
1510
1508
|
return LL2NUM(memo);
|
1511
1509
|
}
|
1512
1510
|
|
1513
|
-
static char *
|
1511
|
+
static char *JSON_decode_integer(JSON_Parser *json, char *p, VALUE *result)
|
1514
1512
|
{
|
1515
|
-
int cs = EVIL;
|
1516
|
-
|
1517
|
-
|
1518
|
-
#line 1519 "parser.c"
|
1519
|
-
{
|
1520
|
-
cs = JSON_integer_start;
|
1521
|
-
}
|
1522
|
-
|
1523
|
-
#line 724 "parser.rl"
|
1524
|
-
json->memo = p;
|
1525
|
-
|
1526
|
-
#line 1527 "parser.c"
|
1527
|
-
{
|
1528
|
-
if ( p == pe )
|
1529
|
-
goto _test_eof;
|
1530
|
-
switch ( cs )
|
1531
|
-
{
|
1532
|
-
case 1:
|
1533
|
-
switch( (*p) ) {
|
1534
|
-
case 45: goto st2;
|
1535
|
-
case 48: goto st3;
|
1536
|
-
}
|
1537
|
-
if ( 49 <= (*p) && (*p) <= 57 )
|
1538
|
-
goto st5;
|
1539
|
-
goto st0;
|
1540
|
-
st0:
|
1541
|
-
cs = 0;
|
1542
|
-
goto _out;
|
1543
|
-
st2:
|
1544
|
-
if ( ++p == pe )
|
1545
|
-
goto _test_eof2;
|
1546
|
-
case 2:
|
1547
|
-
if ( (*p) == 48 )
|
1548
|
-
goto st3;
|
1549
|
-
if ( 49 <= (*p) && (*p) <= 57 )
|
1550
|
-
goto st5;
|
1551
|
-
goto st0;
|
1552
|
-
st3:
|
1553
|
-
if ( ++p == pe )
|
1554
|
-
goto _test_eof3;
|
1555
|
-
case 3:
|
1556
|
-
if ( 48 <= (*p) && (*p) <= 57 )
|
1557
|
-
goto st0;
|
1558
|
-
goto tr4;
|
1559
|
-
tr4:
|
1560
|
-
#line 692 "parser.rl"
|
1561
|
-
{ p--; {p++; cs = 4; goto _out;} }
|
1562
|
-
goto st4;
|
1563
|
-
st4:
|
1564
|
-
if ( ++p == pe )
|
1565
|
-
goto _test_eof4;
|
1566
|
-
case 4:
|
1567
|
-
#line 1568 "parser.c"
|
1568
|
-
goto st0;
|
1569
|
-
st5:
|
1570
|
-
if ( ++p == pe )
|
1571
|
-
goto _test_eof5;
|
1572
|
-
case 5:
|
1573
|
-
if ( 48 <= (*p) && (*p) <= 57 )
|
1574
|
-
goto st5;
|
1575
|
-
goto tr4;
|
1576
|
-
}
|
1577
|
-
_test_eof2: cs = 2; goto _test_eof;
|
1578
|
-
_test_eof3: cs = 3; goto _test_eof;
|
1579
|
-
_test_eof4: cs = 4; goto _test_eof;
|
1580
|
-
_test_eof5: cs = 5; goto _test_eof;
|
1581
|
-
|
1582
|
-
_test_eof: {}
|
1583
|
-
_out: {}
|
1584
|
-
}
|
1585
|
-
|
1586
|
-
#line 726 "parser.rl"
|
1587
|
-
|
1588
|
-
if (cs >= JSON_integer_first_final) {
|
1589
1513
|
long len = p - json->memo;
|
1590
1514
|
if (RB_LIKELY(len < MAX_FAST_INTEGER_SIZE)) {
|
1591
1515
|
*result = fast_parse_integer(json->memo, p);
|
@@ -1596,37 +1520,35 @@ case 5:
|
|
1596
1520
|
*result = rb_cstr2inum(FBUFFER_PTR(&json->fbuffer), 10);
|
1597
1521
|
}
|
1598
1522
|
return p + 1;
|
1599
|
-
} else {
|
1600
|
-
return NULL;
|
1601
|
-
}
|
1602
1523
|
}
|
1603
1524
|
|
1604
1525
|
|
1605
|
-
#line
|
1526
|
+
#line 1527 "parser.c"
|
1606
1527
|
enum {JSON_float_start = 1};
|
1607
|
-
enum {JSON_float_first_final =
|
1528
|
+
enum {JSON_float_first_final = 6};
|
1608
1529
|
enum {JSON_float_error = 0};
|
1609
1530
|
|
1610
1531
|
enum {JSON_float_en_main = 1};
|
1611
1532
|
|
1612
1533
|
|
1613
|
-
#line
|
1534
|
+
#line 745 "parser.rl"
|
1614
1535
|
|
1615
1536
|
|
1616
|
-
static char *
|
1537
|
+
static char *JSON_parse_number(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
1617
1538
|
{
|
1618
1539
|
int cs = EVIL;
|
1540
|
+
bool is_float = false;
|
1619
1541
|
|
1620
1542
|
|
1621
|
-
#line
|
1543
|
+
#line 1544 "parser.c"
|
1622
1544
|
{
|
1623
1545
|
cs = JSON_float_start;
|
1624
1546
|
}
|
1625
1547
|
|
1626
|
-
#line
|
1548
|
+
#line 753 "parser.rl"
|
1627
1549
|
json->memo = p;
|
1628
1550
|
|
1629
|
-
#line
|
1551
|
+
#line 1552 "parser.c"
|
1630
1552
|
{
|
1631
1553
|
if ( p == pe )
|
1632
1554
|
goto _test_eof;
|
@@ -1635,10 +1557,10 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
1635
1557
|
case 1:
|
1636
1558
|
switch( (*p) ) {
|
1637
1559
|
case 45: goto st2;
|
1638
|
-
case 48: goto
|
1560
|
+
case 48: goto st6;
|
1639
1561
|
}
|
1640
1562
|
if ( 49 <= (*p) && (*p) <= 57 )
|
1641
|
-
goto
|
1563
|
+
goto st10;
|
1642
1564
|
goto st0;
|
1643
1565
|
st0:
|
1644
1566
|
cs = 0;
|
@@ -1648,24 +1570,42 @@ st2:
|
|
1648
1570
|
goto _test_eof2;
|
1649
1571
|
case 2:
|
1650
1572
|
if ( (*p) == 48 )
|
1651
|
-
goto
|
1573
|
+
goto st6;
|
1652
1574
|
if ( 49 <= (*p) && (*p) <= 57 )
|
1653
|
-
goto
|
1575
|
+
goto st10;
|
1654
1576
|
goto st0;
|
1655
|
-
|
1577
|
+
st6:
|
1656
1578
|
if ( ++p == pe )
|
1657
|
-
goto
|
1658
|
-
case
|
1579
|
+
goto _test_eof6;
|
1580
|
+
case 6:
|
1659
1581
|
switch( (*p) ) {
|
1660
|
-
case
|
1661
|
-
case
|
1662
|
-
case
|
1582
|
+
case 45: goto st0;
|
1583
|
+
case 46: goto tr8;
|
1584
|
+
case 69: goto tr9;
|
1585
|
+
case 101: goto tr9;
|
1663
1586
|
}
|
1587
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
1588
|
+
goto st0;
|
1589
|
+
goto tr7;
|
1590
|
+
tr7:
|
1591
|
+
#line 737 "parser.rl"
|
1592
|
+
{ p--; {p++; cs = 7; goto _out;} }
|
1593
|
+
goto st7;
|
1594
|
+
st7:
|
1595
|
+
if ( ++p == pe )
|
1596
|
+
goto _test_eof7;
|
1597
|
+
case 7:
|
1598
|
+
#line 1599 "parser.c"
|
1664
1599
|
goto st0;
|
1665
|
-
|
1600
|
+
tr8:
|
1601
|
+
#line 738 "parser.rl"
|
1602
|
+
{ is_float = true; }
|
1603
|
+
goto st3;
|
1604
|
+
st3:
|
1666
1605
|
if ( ++p == pe )
|
1667
|
-
goto
|
1668
|
-
case
|
1606
|
+
goto _test_eof3;
|
1607
|
+
case 3:
|
1608
|
+
#line 1609 "parser.c"
|
1669
1609
|
if ( 48 <= (*p) && (*p) <= 57 )
|
1670
1610
|
goto st8;
|
1671
1611
|
goto st0;
|
@@ -1674,87 +1614,86 @@ st8:
|
|
1674
1614
|
goto _test_eof8;
|
1675
1615
|
case 8:
|
1676
1616
|
switch( (*p) ) {
|
1677
|
-
case 69: goto
|
1678
|
-
case 101: goto
|
1617
|
+
case 69: goto st4;
|
1618
|
+
case 101: goto st4;
|
1679
1619
|
}
|
1680
1620
|
if ( (*p) > 46 ) {
|
1681
1621
|
if ( 48 <= (*p) && (*p) <= 57 )
|
1682
1622
|
goto st8;
|
1683
1623
|
} else if ( (*p) >= 45 )
|
1684
1624
|
goto st0;
|
1685
|
-
goto
|
1625
|
+
goto tr7;
|
1686
1626
|
tr9:
|
1687
|
-
#line
|
1688
|
-
{
|
1689
|
-
goto
|
1690
|
-
|
1691
|
-
if ( ++p == pe )
|
1692
|
-
goto _test_eof9;
|
1693
|
-
case 9:
|
1694
|
-
#line 1695 "parser.c"
|
1695
|
-
goto st0;
|
1696
|
-
st5:
|
1627
|
+
#line 738 "parser.rl"
|
1628
|
+
{ is_float = true; }
|
1629
|
+
goto st4;
|
1630
|
+
st4:
|
1697
1631
|
if ( ++p == pe )
|
1698
|
-
goto
|
1699
|
-
case
|
1632
|
+
goto _test_eof4;
|
1633
|
+
case 4:
|
1634
|
+
#line 1635 "parser.c"
|
1700
1635
|
switch( (*p) ) {
|
1701
|
-
case 43: goto
|
1702
|
-
case 45: goto
|
1636
|
+
case 43: goto st5;
|
1637
|
+
case 45: goto st5;
|
1703
1638
|
}
|
1704
1639
|
if ( 48 <= (*p) && (*p) <= 57 )
|
1705
|
-
goto
|
1640
|
+
goto st9;
|
1706
1641
|
goto st0;
|
1707
|
-
|
1642
|
+
st5:
|
1708
1643
|
if ( ++p == pe )
|
1709
|
-
goto
|
1710
|
-
case
|
1644
|
+
goto _test_eof5;
|
1645
|
+
case 5:
|
1711
1646
|
if ( 48 <= (*p) && (*p) <= 57 )
|
1712
|
-
goto
|
1647
|
+
goto st9;
|
1713
1648
|
goto st0;
|
1714
|
-
|
1649
|
+
st9:
|
1715
1650
|
if ( ++p == pe )
|
1716
|
-
goto
|
1717
|
-
case
|
1651
|
+
goto _test_eof9;
|
1652
|
+
case 9:
|
1718
1653
|
switch( (*p) ) {
|
1719
1654
|
case 69: goto st0;
|
1720
1655
|
case 101: goto st0;
|
1721
1656
|
}
|
1722
1657
|
if ( (*p) > 46 ) {
|
1723
1658
|
if ( 48 <= (*p) && (*p) <= 57 )
|
1724
|
-
goto
|
1659
|
+
goto st9;
|
1725
1660
|
} else if ( (*p) >= 45 )
|
1726
1661
|
goto st0;
|
1727
|
-
goto
|
1728
|
-
|
1662
|
+
goto tr7;
|
1663
|
+
st10:
|
1729
1664
|
if ( ++p == pe )
|
1730
|
-
goto
|
1731
|
-
case
|
1665
|
+
goto _test_eof10;
|
1666
|
+
case 10:
|
1732
1667
|
switch( (*p) ) {
|
1733
|
-
case
|
1734
|
-
case
|
1735
|
-
case
|
1668
|
+
case 45: goto st0;
|
1669
|
+
case 46: goto tr8;
|
1670
|
+
case 69: goto tr9;
|
1671
|
+
case 101: goto tr9;
|
1736
1672
|
}
|
1737
1673
|
if ( 48 <= (*p) && (*p) <= 57 )
|
1738
|
-
goto
|
1739
|
-
goto
|
1674
|
+
goto st10;
|
1675
|
+
goto tr7;
|
1740
1676
|
}
|
1741
1677
|
_test_eof2: cs = 2; goto _test_eof;
|
1678
|
+
_test_eof6: cs = 6; goto _test_eof;
|
1679
|
+
_test_eof7: cs = 7; goto _test_eof;
|
1742
1680
|
_test_eof3: cs = 3; goto _test_eof;
|
1743
|
-
_test_eof4: cs = 4; goto _test_eof;
|
1744
1681
|
_test_eof8: cs = 8; goto _test_eof;
|
1745
|
-
|
1682
|
+
_test_eof4: cs = 4; goto _test_eof;
|
1746
1683
|
_test_eof5: cs = 5; goto _test_eof;
|
1747
|
-
|
1684
|
+
_test_eof9: cs = 9; goto _test_eof;
|
1748
1685
|
_test_eof10: cs = 10; goto _test_eof;
|
1749
|
-
_test_eof7: cs = 7; goto _test_eof;
|
1750
1686
|
|
1751
1687
|
_test_eof: {}
|
1752
1688
|
_out: {}
|
1753
1689
|
}
|
1754
1690
|
|
1755
|
-
#line
|
1691
|
+
#line 755 "parser.rl"
|
1756
1692
|
|
1757
1693
|
if (cs >= JSON_float_first_final) {
|
1694
|
+
if (!is_float) {
|
1695
|
+
return JSON_decode_integer(json, p, result);
|
1696
|
+
}
|
1758
1697
|
VALUE mod = Qnil;
|
1759
1698
|
ID method_id = 0;
|
1760
1699
|
if (json->decimal_class) {
|
@@ -1805,7 +1744,7 @@ case 7:
|
|
1805
1744
|
|
1806
1745
|
|
1807
1746
|
|
1808
|
-
#line
|
1747
|
+
#line 1748 "parser.c"
|
1809
1748
|
enum {JSON_array_start = 1};
|
1810
1749
|
enum {JSON_array_first_final = 22};
|
1811
1750
|
enum {JSON_array_error = 0};
|
@@ -1813,7 +1752,7 @@ enum {JSON_array_error = 0};
|
|
1813
1752
|
enum {JSON_array_en_main = 1};
|
1814
1753
|
|
1815
1754
|
|
1816
|
-
#line
|
1755
|
+
#line 835 "parser.rl"
|
1817
1756
|
|
1818
1757
|
|
1819
1758
|
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
|
@@ -1826,14 +1765,14 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul
|
|
1826
1765
|
long stack_head = json->stack->head;
|
1827
1766
|
|
1828
1767
|
|
1829
|
-
#line
|
1768
|
+
#line 1769 "parser.c"
|
1830
1769
|
{
|
1831
1770
|
cs = JSON_array_start;
|
1832
1771
|
}
|
1833
1772
|
|
1834
|
-
#line
|
1773
|
+
#line 847 "parser.rl"
|
1835
1774
|
|
1836
|
-
#line
|
1775
|
+
#line 1776 "parser.c"
|
1837
1776
|
{
|
1838
1777
|
short _widec;
|
1839
1778
|
if ( p == pe )
|
@@ -1873,7 +1812,7 @@ case 2:
|
|
1873
1812
|
goto st2;
|
1874
1813
|
goto st0;
|
1875
1814
|
tr2:
|
1876
|
-
#line
|
1815
|
+
#line 815 "parser.rl"
|
1877
1816
|
{
|
1878
1817
|
VALUE v = Qnil;
|
1879
1818
|
char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
|
@@ -1888,12 +1827,12 @@ st3:
|
|
1888
1827
|
if ( ++p == pe )
|
1889
1828
|
goto _test_eof3;
|
1890
1829
|
case 3:
|
1891
|
-
#line
|
1830
|
+
#line 1831 "parser.c"
|
1892
1831
|
_widec = (*p);
|
1893
1832
|
if ( 44 <= (*p) && (*p) <= 44 ) {
|
1894
1833
|
_widec = (short)(128 + ((*p) - -128));
|
1895
1834
|
if (
|
1896
|
-
#line
|
1835
|
+
#line 825 "parser.rl"
|
1897
1836
|
json->allow_trailing_comma ) _widec += 256;
|
1898
1837
|
}
|
1899
1838
|
switch( _widec ) {
|
@@ -1940,14 +1879,14 @@ case 7:
|
|
1940
1879
|
goto st3;
|
1941
1880
|
goto st7;
|
1942
1881
|
tr4:
|
1943
|
-
#line
|
1882
|
+
#line 827 "parser.rl"
|
1944
1883
|
{ p--; {p++; cs = 22; goto _out;} }
|
1945
1884
|
goto st22;
|
1946
1885
|
st22:
|
1947
1886
|
if ( ++p == pe )
|
1948
1887
|
goto _test_eof22;
|
1949
1888
|
case 22:
|
1950
|
-
#line
|
1889
|
+
#line 1890 "parser.c"
|
1951
1890
|
goto st0;
|
1952
1891
|
st8:
|
1953
1892
|
if ( ++p == pe )
|
@@ -2015,13 +1954,13 @@ case 13:
|
|
2015
1954
|
if ( 10 <= (*p) && (*p) <= 10 ) {
|
2016
1955
|
_widec = (short)(128 + ((*p) - -128));
|
2017
1956
|
if (
|
2018
|
-
#line
|
1957
|
+
#line 825 "parser.rl"
|
2019
1958
|
json->allow_trailing_comma ) _widec += 256;
|
2020
1959
|
}
|
2021
1960
|
} else if ( (*p) >= 9 ) {
|
2022
1961
|
_widec = (short)(128 + ((*p) - -128));
|
2023
1962
|
if (
|
2024
|
-
#line
|
1963
|
+
#line 825 "parser.rl"
|
2025
1964
|
json->allow_trailing_comma ) _widec += 256;
|
2026
1965
|
}
|
2027
1966
|
} else if ( (*p) > 13 ) {
|
@@ -2029,19 +1968,19 @@ case 13:
|
|
2029
1968
|
if ( 47 <= (*p) && (*p) <= 47 ) {
|
2030
1969
|
_widec = (short)(128 + ((*p) - -128));
|
2031
1970
|
if (
|
2032
|
-
#line
|
1971
|
+
#line 825 "parser.rl"
|
2033
1972
|
json->allow_trailing_comma ) _widec += 256;
|
2034
1973
|
}
|
2035
1974
|
} else if ( (*p) >= 32 ) {
|
2036
1975
|
_widec = (short)(128 + ((*p) - -128));
|
2037
1976
|
if (
|
2038
|
-
#line
|
1977
|
+
#line 825 "parser.rl"
|
2039
1978
|
json->allow_trailing_comma ) _widec += 256;
|
2040
1979
|
}
|
2041
1980
|
} else {
|
2042
1981
|
_widec = (short)(128 + ((*p) - -128));
|
2043
1982
|
if (
|
2044
|
-
#line
|
1983
|
+
#line 825 "parser.rl"
|
2045
1984
|
json->allow_trailing_comma ) _widec += 256;
|
2046
1985
|
}
|
2047
1986
|
switch( _widec ) {
|
@@ -2080,13 +2019,13 @@ case 14:
|
|
2080
2019
|
if ( 47 <= (*p) && (*p) <= 47 ) {
|
2081
2020
|
_widec = (short)(128 + ((*p) - -128));
|
2082
2021
|
if (
|
2083
|
-
#line
|
2022
|
+
#line 825 "parser.rl"
|
2084
2023
|
json->allow_trailing_comma ) _widec += 256;
|
2085
2024
|
}
|
2086
2025
|
} else if ( (*p) >= 42 ) {
|
2087
2026
|
_widec = (short)(128 + ((*p) - -128));
|
2088
2027
|
if (
|
2089
|
-
#line
|
2028
|
+
#line 825 "parser.rl"
|
2090
2029
|
json->allow_trailing_comma ) _widec += 256;
|
2091
2030
|
}
|
2092
2031
|
switch( _widec ) {
|
@@ -2105,20 +2044,20 @@ case 15:
|
|
2105
2044
|
if ( (*p) <= 41 ) {
|
2106
2045
|
_widec = (short)(128 + ((*p) - -128));
|
2107
2046
|
if (
|
2108
|
-
#line
|
2047
|
+
#line 825 "parser.rl"
|
2109
2048
|
json->allow_trailing_comma ) _widec += 256;
|
2110
2049
|
}
|
2111
2050
|
} else if ( (*p) > 42 ) {
|
2112
2051
|
if ( 43 <= (*p) )
|
2113
2052
|
{ _widec = (short)(128 + ((*p) - -128));
|
2114
2053
|
if (
|
2115
|
-
#line
|
2054
|
+
#line 825 "parser.rl"
|
2116
2055
|
json->allow_trailing_comma ) _widec += 256;
|
2117
2056
|
}
|
2118
2057
|
} else {
|
2119
2058
|
_widec = (short)(128 + ((*p) - -128));
|
2120
2059
|
if (
|
2121
|
-
#line
|
2060
|
+
#line 825 "parser.rl"
|
2122
2061
|
json->allow_trailing_comma ) _widec += 256;
|
2123
2062
|
}
|
2124
2063
|
switch( _widec ) {
|
@@ -2141,13 +2080,13 @@ case 16:
|
|
2141
2080
|
if ( 42 <= (*p) && (*p) <= 42 ) {
|
2142
2081
|
_widec = (short)(128 + ((*p) - -128));
|
2143
2082
|
if (
|
2144
|
-
#line
|
2083
|
+
#line 825 "parser.rl"
|
2145
2084
|
json->allow_trailing_comma ) _widec += 256;
|
2146
2085
|
}
|
2147
2086
|
} else {
|
2148
2087
|
_widec = (short)(128 + ((*p) - -128));
|
2149
2088
|
if (
|
2150
|
-
#line
|
2089
|
+
#line 825 "parser.rl"
|
2151
2090
|
json->allow_trailing_comma ) _widec += 256;
|
2152
2091
|
}
|
2153
2092
|
} else if ( (*p) > 46 ) {
|
@@ -2155,19 +2094,19 @@ case 16:
|
|
2155
2094
|
if ( 48 <= (*p) )
|
2156
2095
|
{ _widec = (short)(128 + ((*p) - -128));
|
2157
2096
|
if (
|
2158
|
-
#line
|
2097
|
+
#line 825 "parser.rl"
|
2159
2098
|
json->allow_trailing_comma ) _widec += 256;
|
2160
2099
|
}
|
2161
2100
|
} else if ( (*p) >= 47 ) {
|
2162
2101
|
_widec = (short)(128 + ((*p) - -128));
|
2163
2102
|
if (
|
2164
|
-
#line
|
2103
|
+
#line 825 "parser.rl"
|
2165
2104
|
json->allow_trailing_comma ) _widec += 256;
|
2166
2105
|
}
|
2167
2106
|
} else {
|
2168
2107
|
_widec = (short)(128 + ((*p) - -128));
|
2169
2108
|
if (
|
2170
|
-
#line
|
2109
|
+
#line 825 "parser.rl"
|
2171
2110
|
json->allow_trailing_comma ) _widec += 256;
|
2172
2111
|
}
|
2173
2112
|
switch( _widec ) {
|
@@ -2191,20 +2130,20 @@ case 17:
|
|
2191
2130
|
if ( (*p) <= 9 ) {
|
2192
2131
|
_widec = (short)(128 + ((*p) - -128));
|
2193
2132
|
if (
|
2194
|
-
#line
|
2133
|
+
#line 825 "parser.rl"
|
2195
2134
|
json->allow_trailing_comma ) _widec += 256;
|
2196
2135
|
}
|
2197
2136
|
} else if ( (*p) > 10 ) {
|
2198
2137
|
if ( 11 <= (*p) )
|
2199
2138
|
{ _widec = (short)(128 + ((*p) - -128));
|
2200
2139
|
if (
|
2201
|
-
#line
|
2140
|
+
#line 825 "parser.rl"
|
2202
2141
|
json->allow_trailing_comma ) _widec += 256;
|
2203
2142
|
}
|
2204
2143
|
} else {
|
2205
2144
|
_widec = (short)(128 + ((*p) - -128));
|
2206
2145
|
if (
|
2207
|
-
#line
|
2146
|
+
#line 825 "parser.rl"
|
2208
2147
|
json->allow_trailing_comma ) _widec += 256;
|
2209
2148
|
}
|
2210
2149
|
switch( _widec ) {
|
@@ -2276,7 +2215,7 @@ case 21:
|
|
2276
2215
|
_out: {}
|
2277
2216
|
}
|
2278
2217
|
|
2279
|
-
#line
|
2218
|
+
#line 848 "parser.rl"
|
2280
2219
|
|
2281
2220
|
if(cs >= JSON_array_first_final) {
|
2282
2221
|
long count = json->stack->head - stack_head;
|
@@ -2332,7 +2271,7 @@ static VALUE json_string_fastpath(JSON_Parser *json, char *string, char *stringE
|
|
2332
2271
|
{
|
2333
2272
|
size_t bufferSize = stringEnd - string;
|
2334
2273
|
|
2335
|
-
if (is_name) {
|
2274
|
+
if (is_name && json->in_array) {
|
2336
2275
|
VALUE cached_key;
|
2337
2276
|
if (RB_UNLIKELY(symbolize)) {
|
2338
2277
|
cached_key = rsymbol_cache_fetch(&json->name_cache, string, bufferSize);
|
@@ -2355,7 +2294,7 @@ static VALUE json_string_unescape(JSON_Parser *json, char *string, char *stringE
|
|
2355
2294
|
int unescape_len;
|
2356
2295
|
char buf[4];
|
2357
2296
|
|
2358
|
-
if (is_name) {
|
2297
|
+
if (is_name && json->in_array) {
|
2359
2298
|
VALUE cached_key;
|
2360
2299
|
if (RB_UNLIKELY(symbolize)) {
|
2361
2300
|
cached_key = rsymbol_cache_fetch(&json->name_cache, string, bufferSize);
|
@@ -2470,7 +2409,7 @@ static VALUE json_string_unescape(JSON_Parser *json, char *string, char *stringE
|
|
2470
2409
|
}
|
2471
2410
|
|
2472
2411
|
|
2473
|
-
#line
|
2412
|
+
#line 2413 "parser.c"
|
2474
2413
|
enum {JSON_string_start = 1};
|
2475
2414
|
enum {JSON_string_first_final = 9};
|
2476
2415
|
enum {JSON_string_error = 0};
|
@@ -2478,7 +2417,7 @@ enum {JSON_string_error = 0};
|
|
2478
2417
|
enum {JSON_string_en_main = 1};
|
2479
2418
|
|
2480
2419
|
|
2481
|
-
#line
|
2420
|
+
#line 1071 "parser.rl"
|
2482
2421
|
|
2483
2422
|
|
2484
2423
|
static int
|
@@ -2499,15 +2438,15 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
|
|
2499
2438
|
VALUE match_string;
|
2500
2439
|
|
2501
2440
|
|
2502
|
-
#line
|
2441
|
+
#line 2442 "parser.c"
|
2503
2442
|
{
|
2504
2443
|
cs = JSON_string_start;
|
2505
2444
|
}
|
2506
2445
|
|
2507
|
-
#line
|
2446
|
+
#line 1091 "parser.rl"
|
2508
2447
|
json->memo = p;
|
2509
2448
|
|
2510
|
-
#line
|
2449
|
+
#line 2450 "parser.c"
|
2511
2450
|
{
|
2512
2451
|
if ( p == pe )
|
2513
2452
|
goto _test_eof;
|
@@ -2532,14 +2471,14 @@ case 2:
|
|
2532
2471
|
goto st0;
|
2533
2472
|
goto st2;
|
2534
2473
|
tr2:
|
2535
|
-
#line
|
2474
|
+
#line 1053 "parser.rl"
|
2536
2475
|
{
|
2537
2476
|
*result = json_string_fastpath(json, json->memo + 1, p, json->parsing_name, json->parsing_name || json-> freeze, json->parsing_name && json->symbolize_names);
|
2538
2477
|
{p = (( p + 1))-1;}
|
2539
2478
|
p--;
|
2540
2479
|
{p++; cs = 9; goto _out;}
|
2541
2480
|
}
|
2542
|
-
#line
|
2481
|
+
#line 1046 "parser.rl"
|
2543
2482
|
{
|
2544
2483
|
*result = json_string_unescape(json, json->memo + 1, p, json->parsing_name, json->parsing_name || json-> freeze, json->parsing_name && json->symbolize_names);
|
2545
2484
|
{p = (( p + 1))-1;}
|
@@ -2548,7 +2487,7 @@ tr2:
|
|
2548
2487
|
}
|
2549
2488
|
goto st9;
|
2550
2489
|
tr6:
|
2551
|
-
#line
|
2490
|
+
#line 1046 "parser.rl"
|
2552
2491
|
{
|
2553
2492
|
*result = json_string_unescape(json, json->memo + 1, p, json->parsing_name, json->parsing_name || json-> freeze, json->parsing_name && json->symbolize_names);
|
2554
2493
|
{p = (( p + 1))-1;}
|
@@ -2560,7 +2499,7 @@ st9:
|
|
2560
2499
|
if ( ++p == pe )
|
2561
2500
|
goto _test_eof9;
|
2562
2501
|
case 9:
|
2563
|
-
#line
|
2502
|
+
#line 2503 "parser.c"
|
2564
2503
|
goto st0;
|
2565
2504
|
st3:
|
2566
2505
|
if ( ++p == pe )
|
@@ -2648,7 +2587,7 @@ case 8:
|
|
2648
2587
|
_out: {}
|
2649
2588
|
}
|
2650
2589
|
|
2651
|
-
#line
|
2590
|
+
#line 1093 "parser.rl"
|
2652
2591
|
|
2653
2592
|
if (json->create_additions && RTEST(match_string = json->match_string)) {
|
2654
2593
|
VALUE klass;
|
@@ -2801,7 +2740,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
|
2801
2740
|
}
|
2802
2741
|
|
2803
2742
|
|
2804
|
-
#line
|
2743
|
+
#line 2744 "parser.c"
|
2805
2744
|
enum {JSON_start = 1};
|
2806
2745
|
enum {JSON_first_final = 10};
|
2807
2746
|
enum {JSON_error = 0};
|
@@ -2809,7 +2748,7 @@ enum {JSON_error = 0};
|
|
2809
2748
|
enum {JSON_en_main = 1};
|
2810
2749
|
|
2811
2750
|
|
2812
|
-
#line
|
2751
|
+
#line 1259 "parser.rl"
|
2813
2752
|
|
2814
2753
|
|
2815
2754
|
/*
|
@@ -2838,16 +2777,16 @@ static VALUE cParser_parse(VALUE self)
|
|
2838
2777
|
json->stack = &stack;
|
2839
2778
|
|
2840
2779
|
|
2841
|
-
#line
|
2780
|
+
#line 2781 "parser.c"
|
2842
2781
|
{
|
2843
2782
|
cs = JSON_start;
|
2844
2783
|
}
|
2845
2784
|
|
2846
|
-
#line
|
2785
|
+
#line 1287 "parser.rl"
|
2847
2786
|
p = json->source;
|
2848
2787
|
pe = p + json->len;
|
2849
2788
|
|
2850
|
-
#line
|
2789
|
+
#line 2790 "parser.c"
|
2851
2790
|
{
|
2852
2791
|
if ( p == pe )
|
2853
2792
|
goto _test_eof;
|
@@ -2881,7 +2820,7 @@ st0:
|
|
2881
2820
|
cs = 0;
|
2882
2821
|
goto _out;
|
2883
2822
|
tr2:
|
2884
|
-
#line
|
2823
|
+
#line 1251 "parser.rl"
|
2885
2824
|
{
|
2886
2825
|
char *np = JSON_parse_value(json, p, pe, &result, 0);
|
2887
2826
|
if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
|
@@ -2891,7 +2830,7 @@ st10:
|
|
2891
2830
|
if ( ++p == pe )
|
2892
2831
|
goto _test_eof10;
|
2893
2832
|
case 10:
|
2894
|
-
#line
|
2833
|
+
#line 2834 "parser.c"
|
2895
2834
|
switch( (*p) ) {
|
2896
2835
|
case 13: goto st10;
|
2897
2836
|
case 32: goto st10;
|
@@ -2980,7 +2919,7 @@ case 9:
|
|
2980
2919
|
_out: {}
|
2981
2920
|
}
|
2982
2921
|
|
2983
|
-
#line
|
2922
|
+
#line 1290 "parser.rl"
|
2984
2923
|
|
2985
2924
|
if (json->stack_handle) {
|
2986
2925
|
rvalue_stack_eagerly_release(json->stack_handle);
|
@@ -3016,16 +2955,16 @@ static VALUE cParser_m_parse(VALUE klass, VALUE source, VALUE opts)
|
|
3016
2955
|
json->stack = &stack;
|
3017
2956
|
|
3018
2957
|
|
3019
|
-
#line
|
2958
|
+
#line 2959 "parser.c"
|
3020
2959
|
{
|
3021
2960
|
cs = JSON_start;
|
3022
2961
|
}
|
3023
2962
|
|
3024
|
-
#line
|
2963
|
+
#line 1325 "parser.rl"
|
3025
2964
|
p = json->source;
|
3026
2965
|
pe = p + json->len;
|
3027
2966
|
|
3028
|
-
#line
|
2967
|
+
#line 2968 "parser.c"
|
3029
2968
|
{
|
3030
2969
|
if ( p == pe )
|
3031
2970
|
goto _test_eof;
|
@@ -3059,7 +2998,7 @@ st0:
|
|
3059
2998
|
cs = 0;
|
3060
2999
|
goto _out;
|
3061
3000
|
tr2:
|
3062
|
-
#line
|
3001
|
+
#line 1251 "parser.rl"
|
3063
3002
|
{
|
3064
3003
|
char *np = JSON_parse_value(json, p, pe, &result, 0);
|
3065
3004
|
if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
|
@@ -3069,7 +3008,7 @@ st10:
|
|
3069
3008
|
if ( ++p == pe )
|
3070
3009
|
goto _test_eof10;
|
3071
3010
|
case 10:
|
3072
|
-
#line
|
3011
|
+
#line 3012 "parser.c"
|
3073
3012
|
switch( (*p) ) {
|
3074
3013
|
case 13: goto st10;
|
3075
3014
|
case 32: goto st10;
|
@@ -3158,7 +3097,7 @@ case 9:
|
|
3158
3097
|
_out: {}
|
3159
3098
|
}
|
3160
3099
|
|
3161
|
-
#line
|
3100
|
+
#line 1328 "parser.rl"
|
3162
3101
|
|
3163
3102
|
if (json->stack_handle) {
|
3164
3103
|
rvalue_stack_eagerly_release(json->stack_handle);
|
@@ -392,6 +392,7 @@ typedef struct JSON_ParserStruct {
|
|
392
392
|
VALUE decimal_class;
|
393
393
|
VALUE match_string;
|
394
394
|
FBuffer fbuffer;
|
395
|
+
int in_array;
|
395
396
|
int max_nesting;
|
396
397
|
bool allow_nan;
|
397
398
|
bool allow_trailing_comma;
|
@@ -420,8 +421,7 @@ static const rb_data_type_t JSON_Parser_type;
|
|
420
421
|
static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
421
422
|
static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
|
422
423
|
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
|
423
|
-
static char *
|
424
|
-
static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
424
|
+
static char *JSON_parse_number(JSON_Parser *json, char *p, char *pe, VALUE *result);
|
425
425
|
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
|
426
426
|
|
427
427
|
|
@@ -627,11 +627,7 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
|
|
627
627
|
raise_parse_error("unexpected token at '%s'", p);
|
628
628
|
}
|
629
629
|
}
|
630
|
-
np =
|
631
|
-
if (np != NULL) {
|
632
|
-
fexec np;
|
633
|
-
}
|
634
|
-
np = JSON_parse_integer(json, fpc, pe, result);
|
630
|
+
np = JSON_parse_number(json, fpc, pe, result);
|
635
631
|
if (np != NULL) {
|
636
632
|
fexec np;
|
637
633
|
}
|
@@ -640,7 +636,9 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
|
|
640
636
|
|
641
637
|
action parse_array {
|
642
638
|
char *np;
|
639
|
+
json->in_array++;
|
643
640
|
np = JSON_parse_array(json, fpc, pe, result, current_nesting + 1);
|
641
|
+
json->in_array--;
|
644
642
|
if (np == NULL) { fhold; fbreak; } else fexec np;
|
645
643
|
}
|
646
644
|
|
@@ -716,15 +714,8 @@ static inline VALUE fast_parse_integer(char *p, char *pe)
|
|
716
714
|
return LL2NUM(memo);
|
717
715
|
}
|
718
716
|
|
719
|
-
static char *
|
717
|
+
static char *JSON_decode_integer(JSON_Parser *json, char *p, VALUE *result)
|
720
718
|
{
|
721
|
-
int cs = EVIL;
|
722
|
-
|
723
|
-
%% write init;
|
724
|
-
json->memo = p;
|
725
|
-
%% write exec;
|
726
|
-
|
727
|
-
if (cs >= JSON_integer_first_final) {
|
728
719
|
long len = p - json->memo;
|
729
720
|
if (RB_LIKELY(len < MAX_FAST_INTEGER_SIZE)) {
|
730
721
|
*result = fast_parse_integer(json->memo, p);
|
@@ -735,9 +726,6 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res
|
|
735
726
|
*result = rb_cstr2inum(FBUFFER_PTR(&json->fbuffer), 10);
|
736
727
|
}
|
737
728
|
return p + 1;
|
738
|
-
} else {
|
739
|
-
return NULL;
|
740
|
-
}
|
741
729
|
}
|
742
730
|
|
743
731
|
%%{
|
@@ -747,22 +735,28 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res
|
|
747
735
|
write data;
|
748
736
|
|
749
737
|
action exit { fhold; fbreak; }
|
738
|
+
action isFloat { is_float = true; }
|
750
739
|
|
751
740
|
main := '-'? (
|
752
|
-
(('0' | [1-9][0-9]*)
|
753
|
-
|
754
|
-
|
741
|
+
(('0' | [1-9][0-9]*)
|
742
|
+
((('.' [0-9]+ ([Ee] [+\-]?[0-9]+)?) |
|
743
|
+
([Ee] [+\-]?[0-9]+)) > isFloat)?
|
744
|
+
) (^[0-9Ee.\-]? @exit ));
|
755
745
|
}%%
|
756
746
|
|
757
|
-
static char *
|
747
|
+
static char *JSON_parse_number(JSON_Parser *json, char *p, char *pe, VALUE *result)
|
758
748
|
{
|
759
749
|
int cs = EVIL;
|
750
|
+
bool is_float = false;
|
760
751
|
|
761
752
|
%% write init;
|
762
753
|
json->memo = p;
|
763
754
|
%% write exec;
|
764
755
|
|
765
756
|
if (cs >= JSON_float_first_final) {
|
757
|
+
if (!is_float) {
|
758
|
+
return JSON_decode_integer(json, p, result);
|
759
|
+
}
|
766
760
|
VALUE mod = Qnil;
|
767
761
|
ID method_id = 0;
|
768
762
|
if (json->decimal_class) {
|
@@ -906,7 +900,7 @@ static VALUE json_string_fastpath(JSON_Parser *json, char *string, char *stringE
|
|
906
900
|
{
|
907
901
|
size_t bufferSize = stringEnd - string;
|
908
902
|
|
909
|
-
if (is_name) {
|
903
|
+
if (is_name && json->in_array) {
|
910
904
|
VALUE cached_key;
|
911
905
|
if (RB_UNLIKELY(symbolize)) {
|
912
906
|
cached_key = rsymbol_cache_fetch(&json->name_cache, string, bufferSize);
|
@@ -929,7 +923,7 @@ static VALUE json_string_unescape(JSON_Parser *json, char *string, char *stringE
|
|
929
923
|
int unescape_len;
|
930
924
|
char buf[4];
|
931
925
|
|
932
|
-
if (is_name) {
|
926
|
+
if (is_name && json->in_array) {
|
933
927
|
VALUE cached_key;
|
934
928
|
if (RB_UNLIKELY(symbolize)) {
|
935
929
|
cached_key = rsymbol_cache_fetch(&json->name_cache, string, bufferSize);
|
data/lib/json/common.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#frozen_string_literal: true
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'json/version'
|
3
4
|
|
4
5
|
module JSON
|
@@ -25,7 +26,7 @@ module JSON
|
|
25
26
|
elsif object.respond_to?(:to_str)
|
26
27
|
str = object.to_str
|
27
28
|
if str.is_a?(String)
|
28
|
-
return JSON.parse(
|
29
|
+
return JSON.parse(str, opts)
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
@@ -230,8 +231,8 @@ module JSON
|
|
230
231
|
# parse(File.read(path), opts)
|
231
232
|
#
|
232
233
|
# See method #parse.
|
233
|
-
def load_file(filespec, opts =
|
234
|
-
parse(File.read(filespec), opts)
|
234
|
+
def load_file(filespec, opts = nil)
|
235
|
+
parse(File.read(filespec, encoding: Encoding::UTF_8), opts)
|
235
236
|
end
|
236
237
|
|
237
238
|
# :call-seq:
|
@@ -242,7 +243,7 @@ module JSON
|
|
242
243
|
#
|
243
244
|
# See method #parse!
|
244
245
|
def load_file!(filespec, opts = {})
|
245
|
-
parse!(File.read(filespec), opts)
|
246
|
+
parse!(File.read(filespec, encoding: Encoding::UTF_8), opts)
|
246
247
|
end
|
247
248
|
|
248
249
|
# :call-seq:
|
data/lib/json/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.8.
|
4
|
+
version: 2.8.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: 2024-11-
|
11
|
+
date: 2024-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This is a JSON implementation as a Ruby extension in C.
|
14
14
|
email: flori@ping.de
|