json 2.0.4 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of json might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b03a4476559d2bfc44e9caeb97ff8330abe090c3
4
- data.tar.gz: 18c5c1c5311a254df4f512fa33866268185280e4
3
+ metadata.gz: 24dd1ae30e921611bb63859bc67a08dc3fcb38b8
4
+ data.tar.gz: d89f05b4f72169b9d44f3edc340ef7260c03ea3f
5
5
  SHA512:
6
- metadata.gz: 28bf1fcbba82b0412226c6ba808d91427e19807aab30d7357d55e7004ce17c3673812ad5067d092d6b8039e77b0ea2006251fcb8a9590ed61bc87dc9364c21da
7
- data.tar.gz: 1a1a9702657ad711e48ee470485c5c6101e30ec05b4df6dd0b9d7d524f16f5f0c722f3b672a19e5a6fe9920c014fcb857f6dcfb416ac657cab91dd3bc228be37
6
+ metadata.gz: 2f318d952d54391162c511761b6705147d81493397d62b236052822a9178b9b950eb845f3ae9492b1fcdb416e7e1356e6dc1a648c69da974e87b4301e9675030
7
+ data.tar.gz: ebed34cc77dcdf05f75a4aebf8d345e77a75cb2a7e7f1afeab0a2fc0a7172bceea1ddec5fbb15e492835d92b16564093826757d330fea19270d90a2a501c1598
@@ -9,7 +9,7 @@ rvm:
9
9
  - 2.1
10
10
  - 2.2
11
11
  - 2.3.3
12
- - 2.4.0
12
+ - 2.4.1
13
13
  - jruby
14
14
  - ruby-head
15
15
  matrix:
data/CHANGES.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changes
2
2
 
3
+ ## 2017-04-18 (2.1.0)
4
+ * Allow passing of `decimal_class` option to specify a class as which to parse
5
+ JSON float numbers.
3
6
  ## 2017-03-23 (2.0.4)
4
7
  * Raise exception for incomplete unicode surrogates/character escape
5
8
  sequences. This problem was reported by Daniel Gollahon (dgollahon).
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ source 'https://rubygems.org'
5
5
  case ENV['JSON']
6
6
  when 'ext', nil
7
7
  if ENV['RUBY_ENGINE'] == 'jruby'
8
- gemspec :name => 'json', :path => 'java'
8
+ gemspec :name => 'json-java'
9
9
  else
10
10
  gemspec :name => 'json'
11
11
  end
data/Rakefile CHANGED
@@ -257,7 +257,7 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
257
257
  end
258
258
 
259
259
  desc "Testing library (jruby)"
260
- task :test_ext => [ :create_jar, :check_env, :do_test_ext ]
260
+ task :test_ext => [ :check_env, :create_jar, :do_test_ext ]
261
261
 
262
262
  UndocumentedTestTask.new do |t|
263
263
  t.name = 'do_test_ext'
@@ -331,7 +331,7 @@ else
331
331
  end
332
332
 
333
333
  desc "Testing library (extension)"
334
- task :test_ext => [ :compile, :check_env, :do_test_ext ]
334
+ task :test_ext => [ :check_env, :compile, :do_test_ext ]
335
335
 
336
336
  UndocumentedTestTask.new do |t|
337
337
  t.name = 'do_test_ext'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.4
1
+ 2.1.0
@@ -94,15 +94,16 @@ static VALUE CNaN, CInfinity, CMinusInfinity;
94
94
 
95
95
  static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
96
96
  i_chr, i_max_nesting, i_allow_nan, i_symbolize_names,
97
- i_object_class, i_array_class, i_key_p, i_deep_const_get, i_match,
98
- i_match_string, i_aset, i_aref, i_leftshift;
97
+ i_object_class, i_array_class, i_decimal_class, i_key_p,
98
+ i_deep_const_get, i_match, i_match_string, i_aset, i_aref,
99
+ i_leftshift, i_new;
99
100
 
100
101
 
101
- #line 124 "parser.rl"
102
+ #line 125 "parser.rl"
102
103
 
103
104
 
104
105
 
105
- #line 106 "parser.c"
106
+ #line 107 "parser.c"
106
107
  enum {JSON_object_start = 1};
107
108
  enum {JSON_object_first_final = 27};
108
109
  enum {JSON_object_error = 0};
@@ -110,7 +111,7 @@ enum {JSON_object_error = 0};
110
111
  enum {JSON_object_en_main = 1};
111
112
 
112
113
 
113
- #line 165 "parser.rl"
114
+ #line 166 "parser.rl"
114
115
 
115
116
 
116
117
  static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -126,14 +127,14 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
126
127
  *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
127
128
 
128
129
 
129
- #line 130 "parser.c"
130
+ #line 131 "parser.c"
130
131
  {
131
132
  cs = JSON_object_start;
132
133
  }
133
134
 
134
- #line 180 "parser.rl"
135
+ #line 181 "parser.rl"
135
136
 
136
- #line 137 "parser.c"
137
+ #line 138 "parser.c"
137
138
  {
138
139
  if ( p == pe )
139
140
  goto _test_eof;
@@ -161,7 +162,7 @@ case 2:
161
162
  goto st2;
162
163
  goto st0;
163
164
  tr2:
164
- #line 147 "parser.rl"
165
+ #line 148 "parser.rl"
165
166
  {
166
167
  char *np;
167
168
  json->parsing_name = 1;
@@ -174,7 +175,7 @@ st3:
174
175
  if ( ++p == pe )
175
176
  goto _test_eof3;
176
177
  case 3:
177
- #line 178 "parser.c"
178
+ #line 179 "parser.c"
178
179
  switch( (*p) ) {
179
180
  case 13: goto st3;
180
181
  case 32: goto st3;
@@ -241,7 +242,7 @@ case 8:
241
242
  goto st8;
242
243
  goto st0;
243
244
  tr11:
244
- #line 132 "parser.rl"
245
+ #line 133 "parser.rl"
245
246
  {
246
247
  VALUE v = Qnil;
247
248
  char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
@@ -261,7 +262,7 @@ st9:
261
262
  if ( ++p == pe )
262
263
  goto _test_eof9;
263
264
  case 9:
264
- #line 265 "parser.c"
265
+ #line 266 "parser.c"
265
266
  switch( (*p) ) {
266
267
  case 13: goto st9;
267
268
  case 32: goto st9;
@@ -350,14 +351,14 @@ case 18:
350
351
  goto st9;
351
352
  goto st18;
352
353
  tr4:
353
- #line 155 "parser.rl"
354
+ #line 156 "parser.rl"
354
355
  { p--; {p++; cs = 27; goto _out;} }
355
356
  goto st27;
356
357
  st27:
357
358
  if ( ++p == pe )
358
359
  goto _test_eof27;
359
360
  case 27:
360
- #line 361 "parser.c"
361
+ #line 362 "parser.c"
361
362
  goto st0;
362
363
  st19:
363
364
  if ( ++p == pe )
@@ -455,7 +456,7 @@ case 26:
455
456
  _out: {}
456
457
  }
457
458
 
458
- #line 181 "parser.rl"
459
+ #line 182 "parser.rl"
459
460
 
460
461
  if (cs >= JSON_object_first_final) {
461
462
  if (json->create_additions) {
@@ -480,7 +481,7 @@ case 26:
480
481
 
481
482
 
482
483
 
483
- #line 484 "parser.c"
484
+ #line 485 "parser.c"
484
485
  enum {JSON_value_start = 1};
485
486
  enum {JSON_value_first_final = 29};
486
487
  enum {JSON_value_error = 0};
@@ -488,7 +489,7 @@ enum {JSON_value_error = 0};
488
489
  enum {JSON_value_en_main = 1};
489
490
 
490
491
 
491
- #line 281 "parser.rl"
492
+ #line 282 "parser.rl"
492
493
 
493
494
 
494
495
  static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -496,14 +497,14 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
496
497
  int cs = EVIL;
497
498
 
498
499
 
499
- #line 500 "parser.c"
500
+ #line 501 "parser.c"
500
501
  {
501
502
  cs = JSON_value_start;
502
503
  }
503
504
 
504
- #line 288 "parser.rl"
505
+ #line 289 "parser.rl"
505
506
 
506
- #line 507 "parser.c"
507
+ #line 508 "parser.c"
507
508
  {
508
509
  if ( p == pe )
509
510
  goto _test_eof;
@@ -537,14 +538,14 @@ st0:
537
538
  cs = 0;
538
539
  goto _out;
539
540
  tr2:
540
- #line 233 "parser.rl"
541
+ #line 234 "parser.rl"
541
542
  {
542
543
  char *np = JSON_parse_string(json, p, pe, result);
543
544
  if (np == NULL) { p--; {p++; cs = 29; goto _out;} } else {p = (( np))-1;}
544
545
  }
545
546
  goto st29;
546
547
  tr3:
547
- #line 238 "parser.rl"
548
+ #line 239 "parser.rl"
548
549
  {
549
550
  char *np;
550
551
  if(pe > p + 8 && !strncmp(MinusInfinity, p, 9)) {
@@ -564,7 +565,7 @@ tr3:
564
565
  }
565
566
  goto st29;
566
567
  tr7:
567
- #line 256 "parser.rl"
568
+ #line 257 "parser.rl"
568
569
  {
569
570
  char *np;
570
571
  np = JSON_parse_array(json, p, pe, result, current_nesting + 1);
@@ -572,7 +573,7 @@ tr7:
572
573
  }
573
574
  goto st29;
574
575
  tr11:
575
- #line 262 "parser.rl"
576
+ #line 263 "parser.rl"
576
577
  {
577
578
  char *np;
578
579
  np = JSON_parse_object(json, p, pe, result, current_nesting + 1);
@@ -580,7 +581,7 @@ tr11:
580
581
  }
581
582
  goto st29;
582
583
  tr25:
583
- #line 226 "parser.rl"
584
+ #line 227 "parser.rl"
584
585
  {
585
586
  if (json->allow_nan) {
586
587
  *result = CInfinity;
@@ -590,7 +591,7 @@ tr25:
590
591
  }
591
592
  goto st29;
592
593
  tr27:
593
- #line 219 "parser.rl"
594
+ #line 220 "parser.rl"
594
595
  {
595
596
  if (json->allow_nan) {
596
597
  *result = CNaN;
@@ -600,19 +601,19 @@ tr27:
600
601
  }
601
602
  goto st29;
602
603
  tr31:
603
- #line 213 "parser.rl"
604
+ #line 214 "parser.rl"
604
605
  {
605
606
  *result = Qfalse;
606
607
  }
607
608
  goto st29;
608
609
  tr34:
609
- #line 210 "parser.rl"
610
+ #line 211 "parser.rl"
610
611
  {
611
612
  *result = Qnil;
612
613
  }
613
614
  goto st29;
614
615
  tr37:
615
- #line 216 "parser.rl"
616
+ #line 217 "parser.rl"
616
617
  {
617
618
  *result = Qtrue;
618
619
  }
@@ -621,9 +622,9 @@ st29:
621
622
  if ( ++p == pe )
622
623
  goto _test_eof29;
623
624
  case 29:
624
- #line 268 "parser.rl"
625
+ #line 269 "parser.rl"
625
626
  { p--; {p++; cs = 29; goto _out;} }
626
- #line 627 "parser.c"
627
+ #line 628 "parser.c"
627
628
  switch( (*p) ) {
628
629
  case 13: goto st29;
629
630
  case 32: goto st29;
@@ -864,7 +865,7 @@ case 28:
864
865
  _out: {}
865
866
  }
866
867
 
867
- #line 289 "parser.rl"
868
+ #line 290 "parser.rl"
868
869
 
869
870
  if (cs >= JSON_value_first_final) {
870
871
  return p;
@@ -874,7 +875,7 @@ case 28:
874
875
  }
875
876
 
876
877
 
877
- #line 878 "parser.c"
878
+ #line 879 "parser.c"
878
879
  enum {JSON_integer_start = 1};
879
880
  enum {JSON_integer_first_final = 3};
880
881
  enum {JSON_integer_error = 0};
@@ -882,7 +883,7 @@ enum {JSON_integer_error = 0};
882
883
  enum {JSON_integer_en_main = 1};
883
884
 
884
885
 
885
- #line 305 "parser.rl"
886
+ #line 306 "parser.rl"
886
887
 
887
888
 
888
889
  static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
@@ -890,15 +891,15 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res
890
891
  int cs = EVIL;
891
892
 
892
893
 
893
- #line 894 "parser.c"
894
+ #line 895 "parser.c"
894
895
  {
895
896
  cs = JSON_integer_start;
896
897
  }
897
898
 
898
- #line 312 "parser.rl"
899
+ #line 313 "parser.rl"
899
900
  json->memo = p;
900
901
 
901
- #line 902 "parser.c"
902
+ #line 903 "parser.c"
902
903
  {
903
904
  if ( p == pe )
904
905
  goto _test_eof;
@@ -932,14 +933,14 @@ case 3:
932
933
  goto st0;
933
934
  goto tr4;
934
935
  tr4:
935
- #line 302 "parser.rl"
936
+ #line 303 "parser.rl"
936
937
  { p--; {p++; cs = 4; goto _out;} }
937
938
  goto st4;
938
939
  st4:
939
940
  if ( ++p == pe )
940
941
  goto _test_eof4;
941
942
  case 4:
942
- #line 943 "parser.c"
943
+ #line 944 "parser.c"
943
944
  goto st0;
944
945
  st5:
945
946
  if ( ++p == pe )
@@ -958,7 +959,7 @@ case 5:
958
959
  _out: {}
959
960
  }
960
961
 
961
- #line 314 "parser.rl"
962
+ #line 315 "parser.rl"
962
963
 
963
964
  if (cs >= JSON_integer_first_final) {
964
965
  long len = p - json->memo;
@@ -973,7 +974,7 @@ case 5:
973
974
  }
974
975
 
975
976
 
976
- #line 977 "parser.c"
977
+ #line 978 "parser.c"
977
978
  enum {JSON_float_start = 1};
978
979
  enum {JSON_float_first_final = 8};
979
980
  enum {JSON_float_error = 0};
@@ -981,7 +982,7 @@ enum {JSON_float_error = 0};
981
982
  enum {JSON_float_en_main = 1};
982
983
 
983
984
 
984
- #line 339 "parser.rl"
985
+ #line 340 "parser.rl"
985
986
 
986
987
 
987
988
  static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
@@ -989,15 +990,15 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul
989
990
  int cs = EVIL;
990
991
 
991
992
 
992
- #line 993 "parser.c"
993
+ #line 994 "parser.c"
993
994
  {
994
995
  cs = JSON_float_start;
995
996
  }
996
997
 
997
- #line 346 "parser.rl"
998
+ #line 347 "parser.rl"
998
999
  json->memo = p;
999
1000
 
1000
- #line 1001 "parser.c"
1001
+ #line 1002 "parser.c"
1001
1002
  {
1002
1003
  if ( p == pe )
1003
1004
  goto _test_eof;
@@ -1055,14 +1056,14 @@ case 8:
1055
1056
  goto st0;
1056
1057
  goto tr9;
1057
1058
  tr9:
1058
- #line 333 "parser.rl"
1059
+ #line 334 "parser.rl"
1059
1060
  { p--; {p++; cs = 9; goto _out;} }
1060
1061
  goto st9;
1061
1062
  st9:
1062
1063
  if ( ++p == pe )
1063
1064
  goto _test_eof9;
1064
1065
  case 9:
1065
- #line 1066 "parser.c"
1066
+ #line 1067 "parser.c"
1066
1067
  goto st0;
1067
1068
  st5:
1068
1069
  if ( ++p == pe )
@@ -1123,14 +1124,20 @@ case 7:
1123
1124
  _out: {}
1124
1125
  }
1125
1126
 
1126
- #line 348 "parser.rl"
1127
+ #line 349 "parser.rl"
1127
1128
 
1128
1129
  if (cs >= JSON_float_first_final) {
1129
1130
  long len = p - json->memo;
1130
1131
  fbuffer_clear(json->fbuffer);
1131
1132
  fbuffer_append(json->fbuffer, json->memo, len);
1132
1133
  fbuffer_append_char(json->fbuffer, '\0');
1133
- *result = rb_float_new(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1));
1134
+ if (NIL_P(json->decimal_class)) {
1135
+ *result = rb_float_new(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1));
1136
+ } else {
1137
+ VALUE text;
1138
+ text = rb_str_new2(FBUFFER_PTR(json->fbuffer));
1139
+ *result = rb_funcall(json->decimal_class, i_new, 1, text);
1140
+ }
1134
1141
  return p + 1;
1135
1142
  } else {
1136
1143
  return NULL;
@@ -1139,7 +1146,7 @@ case 7:
1139
1146
 
1140
1147
 
1141
1148
 
1142
- #line 1143 "parser.c"
1149
+ #line 1150 "parser.c"
1143
1150
  enum {JSON_array_start = 1};
1144
1151
  enum {JSON_array_first_final = 17};
1145
1152
  enum {JSON_array_error = 0};
@@ -1147,7 +1154,7 @@ enum {JSON_array_error = 0};
1147
1154
  enum {JSON_array_en_main = 1};
1148
1155
 
1149
1156
 
1150
- #line 391 "parser.rl"
1157
+ #line 398 "parser.rl"
1151
1158
 
1152
1159
 
1153
1160
  static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -1161,14 +1168,14 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul
1161
1168
  *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
1162
1169
 
1163
1170
 
1164
- #line 1165 "parser.c"
1171
+ #line 1172 "parser.c"
1165
1172
  {
1166
1173
  cs = JSON_array_start;
1167
1174
  }
1168
1175
 
1169
- #line 404 "parser.rl"
1176
+ #line 411 "parser.rl"
1170
1177
 
1171
- #line 1172 "parser.c"
1178
+ #line 1179 "parser.c"
1172
1179
  {
1173
1180
  if ( p == pe )
1174
1181
  goto _test_eof;
@@ -1207,7 +1214,7 @@ case 2:
1207
1214
  goto st2;
1208
1215
  goto st0;
1209
1216
  tr2:
1210
- #line 368 "parser.rl"
1217
+ #line 375 "parser.rl"
1211
1218
  {
1212
1219
  VALUE v = Qnil;
1213
1220
  char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
@@ -1227,7 +1234,7 @@ st3:
1227
1234
  if ( ++p == pe )
1228
1235
  goto _test_eof3;
1229
1236
  case 3:
1230
- #line 1231 "parser.c"
1237
+ #line 1238 "parser.c"
1231
1238
  switch( (*p) ) {
1232
1239
  case 13: goto st3;
1233
1240
  case 32: goto st3;
@@ -1327,14 +1334,14 @@ case 12:
1327
1334
  goto st3;
1328
1335
  goto st12;
1329
1336
  tr4:
1330
- #line 383 "parser.rl"
1337
+ #line 390 "parser.rl"
1331
1338
  { p--; {p++; cs = 17; goto _out;} }
1332
1339
  goto st17;
1333
1340
  st17:
1334
1341
  if ( ++p == pe )
1335
1342
  goto _test_eof17;
1336
1343
  case 17:
1337
- #line 1338 "parser.c"
1344
+ #line 1345 "parser.c"
1338
1345
  goto st0;
1339
1346
  st13:
1340
1347
  if ( ++p == pe )
@@ -1390,7 +1397,7 @@ case 16:
1390
1397
  _out: {}
1391
1398
  }
1392
1399
 
1393
- #line 405 "parser.rl"
1400
+ #line 412 "parser.rl"
1394
1401
 
1395
1402
  if(cs >= JSON_array_first_final) {
1396
1403
  return p + 1;
@@ -1479,7 +1486,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
1479
1486
  }
1480
1487
 
1481
1488
 
1482
- #line 1483 "parser.c"
1489
+ #line 1490 "parser.c"
1483
1490
  enum {JSON_string_start = 1};
1484
1491
  enum {JSON_string_first_final = 8};
1485
1492
  enum {JSON_string_error = 0};
@@ -1487,7 +1494,7 @@ enum {JSON_string_error = 0};
1487
1494
  enum {JSON_string_en_main = 1};
1488
1495
 
1489
1496
 
1490
- #line 512 "parser.rl"
1497
+ #line 519 "parser.rl"
1491
1498
 
1492
1499
 
1493
1500
  static int
@@ -1509,15 +1516,15 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
1509
1516
 
1510
1517
  *result = rb_str_buf_new(0);
1511
1518
 
1512
- #line 1513 "parser.c"
1519
+ #line 1520 "parser.c"
1513
1520
  {
1514
1521
  cs = JSON_string_start;
1515
1522
  }
1516
1523
 
1517
- #line 533 "parser.rl"
1524
+ #line 540 "parser.rl"
1518
1525
  json->memo = p;
1519
1526
 
1520
- #line 1521 "parser.c"
1527
+ #line 1528 "parser.c"
1521
1528
  {
1522
1529
  if ( p == pe )
1523
1530
  goto _test_eof;
@@ -1542,7 +1549,7 @@ case 2:
1542
1549
  goto st0;
1543
1550
  goto st2;
1544
1551
  tr2:
1545
- #line 498 "parser.rl"
1552
+ #line 505 "parser.rl"
1546
1553
  {
1547
1554
  *result = json_string_unescape(*result, json->memo + 1, p);
1548
1555
  if (NIL_P(*result)) {
@@ -1553,14 +1560,14 @@ tr2:
1553
1560
  {p = (( p + 1))-1;}
1554
1561
  }
1555
1562
  }
1556
- #line 509 "parser.rl"
1563
+ #line 516 "parser.rl"
1557
1564
  { p--; {p++; cs = 8; goto _out;} }
1558
1565
  goto st8;
1559
1566
  st8:
1560
1567
  if ( ++p == pe )
1561
1568
  goto _test_eof8;
1562
1569
  case 8:
1563
- #line 1564 "parser.c"
1570
+ #line 1571 "parser.c"
1564
1571
  goto st0;
1565
1572
  st3:
1566
1573
  if ( ++p == pe )
@@ -1636,7 +1643,7 @@ case 7:
1636
1643
  _out: {}
1637
1644
  }
1638
1645
 
1639
- #line 535 "parser.rl"
1646
+ #line 542 "parser.rl"
1640
1647
 
1641
1648
  if (json->create_additions && RTEST(match_string = json->match_string)) {
1642
1649
  VALUE klass;
@@ -1789,6 +1796,12 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
1789
1796
  } else {
1790
1797
  json->array_class = Qnil;
1791
1798
  }
1799
+ tmp = ID2SYM(i_decimal_class);
1800
+ if (option_given_p(opts, tmp)) {
1801
+ json->decimal_class = rb_hash_aref(opts, tmp);
1802
+ } else {
1803
+ json->decimal_class = Qnil;
1804
+ }
1792
1805
  tmp = ID2SYM(i_match_string);
1793
1806
  if (option_given_p(opts, tmp)) {
1794
1807
  VALUE match_string = rb_hash_aref(opts, tmp);
@@ -1806,6 +1819,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
1806
1819
  json->create_id = rb_funcall(mJSON, i_create_id, 0);
1807
1820
  json->object_class = Qnil;
1808
1821
  json->array_class = Qnil;
1822
+ json->decimal_class = Qnil;
1809
1823
  }
1810
1824
  source = convert_encoding(StringValue(source));
1811
1825
  StringValue(source);
@@ -1816,7 +1830,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
1816
1830
  }
1817
1831
 
1818
1832
 
1819
- #line 1820 "parser.c"
1833
+ #line 1834 "parser.c"
1820
1834
  enum {JSON_start = 1};
1821
1835
  enum {JSON_first_final = 10};
1822
1836
  enum {JSON_error = 0};
@@ -1824,7 +1838,7 @@ enum {JSON_error = 0};
1824
1838
  enum {JSON_en_main = 1};
1825
1839
 
1826
1840
 
1827
- #line 728 "parser.rl"
1841
+ #line 742 "parser.rl"
1828
1842
 
1829
1843
 
1830
1844
  /*
@@ -1841,16 +1855,16 @@ static VALUE cParser_parse(VALUE self)
1841
1855
  GET_PARSER;
1842
1856
 
1843
1857
 
1844
- #line 1845 "parser.c"
1858
+ #line 1859 "parser.c"
1845
1859
  {
1846
1860
  cs = JSON_start;
1847
1861
  }
1848
1862
 
1849
- #line 744 "parser.rl"
1863
+ #line 758 "parser.rl"
1850
1864
  p = json->source;
1851
1865
  pe = p + json->len;
1852
1866
 
1853
- #line 1854 "parser.c"
1867
+ #line 1868 "parser.c"
1854
1868
  {
1855
1869
  if ( p == pe )
1856
1870
  goto _test_eof;
@@ -1884,7 +1898,7 @@ st0:
1884
1898
  cs = 0;
1885
1899
  goto _out;
1886
1900
  tr2:
1887
- #line 720 "parser.rl"
1901
+ #line 734 "parser.rl"
1888
1902
  {
1889
1903
  char *np = JSON_parse_value(json, p, pe, &result, 0);
1890
1904
  if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
@@ -1894,7 +1908,7 @@ st10:
1894
1908
  if ( ++p == pe )
1895
1909
  goto _test_eof10;
1896
1910
  case 10:
1897
- #line 1898 "parser.c"
1911
+ #line 1912 "parser.c"
1898
1912
  switch( (*p) ) {
1899
1913
  case 13: goto st10;
1900
1914
  case 32: goto st10;
@@ -1983,7 +1997,7 @@ case 9:
1983
1997
  _out: {}
1984
1998
  }
1985
1999
 
1986
- #line 747 "parser.rl"
2000
+ #line 761 "parser.rl"
1987
2001
 
1988
2002
  if (cs >= JSON_first_final && p == pe) {
1989
2003
  return result;
@@ -2000,6 +2014,7 @@ static void JSON_mark(void *ptr)
2000
2014
  rb_gc_mark_maybe(json->create_id);
2001
2015
  rb_gc_mark_maybe(json->object_class);
2002
2016
  rb_gc_mark_maybe(json->array_class);
2017
+ rb_gc_mark_maybe(json->decimal_class);
2003
2018
  rb_gc_mark_maybe(json->match_string);
2004
2019
  }
2005
2020
 
@@ -2074,6 +2089,7 @@ void Init_parser(void)
2074
2089
  i_symbolize_names = rb_intern("symbolize_names");
2075
2090
  i_object_class = rb_intern("object_class");
2076
2091
  i_array_class = rb_intern("array_class");
2092
+ i_decimal_class = rb_intern("decimal_class");
2077
2093
  i_match = rb_intern("match");
2078
2094
  i_match_string = rb_intern("match_string");
2079
2095
  i_key_p = rb_intern("key?");
@@ -2081,6 +2097,7 @@ void Init_parser(void)
2081
2097
  i_aset = rb_intern("[]=");
2082
2098
  i_aref = rb_intern("[]");
2083
2099
  i_leftshift = rb_intern("<<");
2100
+ i_new = rb_intern("new");
2084
2101
  }
2085
2102
 
2086
2103
  /*