json 2.1.0 → 2.2.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
- SHA1:
3
- metadata.gz: 24dd1ae30e921611bb63859bc67a08dc3fcb38b8
4
- data.tar.gz: d89f05b4f72169b9d44f3edc340ef7260c03ea3f
2
+ SHA256:
3
+ metadata.gz: 0d5aa01bc44bdf00e8465d5acbde009357987e98ac653672feba63b81f98dfc8
4
+ data.tar.gz: 5845322c2daa41d815c4b845c6561d2addf86b459a5c093590317210d6d85901
5
5
  SHA512:
6
- metadata.gz: 2f318d952d54391162c511761b6705147d81493397d62b236052822a9178b9b950eb845f3ae9492b1fcdb416e7e1356e6dc1a648c69da974e87b4301e9675030
7
- data.tar.gz: ebed34cc77dcdf05f75a4aebf8d345e77a75cb2a7e7f1afeab0a2fc0a7172bceea1ddec5fbb15e492835d92b16564093826757d330fea19270d90a2a501c1598
6
+ metadata.gz: f553341d9b8c4d20788255a35a48816a59cacb408f183e8a6009ab9326b66d80078961d4cc9da8e62155e4bb00f31dedddb449cf30afdb386ab6b49e248299dd
7
+ data.tar.gz: e74601af87a7ec32952fd596b4981b0d26c4f96ddb88979a26b2fb06604dff204d38ba7c120cd0389756edb83cbd81b6fc569d16f5f7740b8b2915d63cdc8f22
@@ -8,12 +8,16 @@ rvm:
8
8
  - 2.0.0
9
9
  - 2.1
10
10
  - 2.2
11
- - 2.3.3
12
- - 2.4.1
13
- - jruby
11
+ - 2.3
12
+ - 2.4
13
+ - 2.5
14
+ - 2.6
14
15
  - ruby-head
16
+ - jruby
15
17
  matrix:
16
18
  allow_failures:
19
+ - rvm: 1.9.3
17
20
  - rvm: ruby-head
21
+ - rvm: jruby
18
22
  script: "bundle exec rake"
19
23
  sudo: false
data/CHANGES.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changes
2
2
 
3
+ ## 2019-02-21 (2.2.0)
4
+ * Adds support for 2.6 BigDecimal and ruby standard library Set datetype.
5
+
3
6
  ## 2017-04-18 (2.1.0)
4
7
  * Allow passing of `decimal_class` option to specify a class as which to parse
5
8
  JSON float numbers.
data/Gemfile CHANGED
@@ -12,5 +12,3 @@ when 'ext', nil
12
12
  when 'pure'
13
13
  gemspec :name => 'json_pure'
14
14
  end
15
-
16
- gem 'simplecov'
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
- # JSON implementation for Ruby ![Travis Widget]
2
- [Travis Widget]: http://travis-ci.org/flori/json.svg?branch=master
1
+ # JSON implementation for Ruby
2
+
3
+ [![Travis Widget](http://travis-ci.org/flori/json.svg?branch=master)](https://travis-ci.org/flori/json)
3
4
 
4
5
  ## Description
5
6
 
@@ -150,6 +151,18 @@ require 'json/add/rails'
150
151
  Both of the additions attempt to require `'json'` (like above) first, if it has
151
152
  not been required yet.
152
153
 
154
+ ## Serializing exceptions
155
+
156
+ The JSON module doesn't extend `Exception` by default. If you convert an `Exception`
157
+ object to JSON, it will by default only include the exception message.
158
+
159
+ To include the full details, you must either load the `json/add/core` mentioned
160
+ above, or specifically load the exception addition:
161
+
162
+ ```ruby
163
+ require 'json/add/exception'
164
+ ```
165
+
153
166
  ## More Examples
154
167
 
155
168
  To create a JSON document from a ruby data structure, you can call
@@ -179,14 +192,14 @@ should return a JSON object (a hash converted to JSON with `#to_json`) like
179
192
  this (don't forget the `*a` for all the arguments):
180
193
 
181
194
  ```ruby
182
- class Range
183
- def to_json(*a)
184
- {
185
- 'json_class' => self.class.name, # = 'Range'
186
- 'data' => [ first, last, exclude_end? ]
187
- }.to_json(*a)
188
- end
189
- end
195
+ class Range
196
+ def to_json(*a)
197
+ {
198
+ 'json_class' => self.class.name, # = 'Range'
199
+ 'data' => [ first, last, exclude_end? ]
200
+ }.to_json(*a)
201
+ end
202
+ end
190
203
  ```
191
204
 
192
205
  The hash key `json_class` is the class, that will be asked to deserialise the
@@ -194,26 +207,30 @@ JSON representation later. In this case it's `Range`, but any namespace of
194
207
  the form `A::B` or `::A::B` will do. All other keys are arbitrary and can be
195
208
  used to store the necessary data to configure the object to be deserialised.
196
209
 
197
- If a the key `json_class` is found in a JSON object, the JSON parser checks
210
+ If the key `json_class` is found in a JSON object, the JSON parser checks
198
211
  if the given class responds to the `json_create` class method. If so, it is
199
212
  called with the JSON object converted to a Ruby hash. So a range can
200
213
  be deserialised by implementing `Range.json_create` like this:
201
214
 
202
215
  ```ruby
203
- class Range
204
- def self.json_create(o)
205
- new(*o['data'])
206
- end
207
- end
216
+ class Range
217
+ def self.json_create(o)
218
+ new(*o['data'])
219
+ end
220
+ end
208
221
  ```
209
222
 
210
223
  Now it possible to serialise/deserialise ranges as well:
211
224
 
212
225
  ```ruby
213
- json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
214
- # => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
215
- JSON.parse json
216
- # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
226
+ json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
227
+ # => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
228
+ JSON.parse json
229
+ # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
230
+ json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
231
+ # => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
232
+ JSON.parse json, :create_additions => true
233
+ # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
217
234
  ```
218
235
 
219
236
  `JSON.generate` always creates the shortest possible string representation of a
data/Rakefile CHANGED
@@ -238,7 +238,7 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
238
238
  classpath = (Dir['java/lib/*.jar'] << 'java/src' << JRUBY_JAR) * ':'
239
239
  obj = src.sub(/\.java\Z/, '.class')
240
240
  file obj => src do
241
- sh 'javac', '-classpath', classpath, '-source', '1.5', '-target', '1.5', src
241
+ sh 'javac', '-classpath', classpath, '-source', '1.6', '-target', '1.6', src
242
242
  end
243
243
  JAVA_CLASSES << obj
244
244
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.2.0
@@ -1335,6 +1335,7 @@ static VALUE cState_buffer_initial_length_set(VALUE self, VALUE buffer_initial_l
1335
1335
  */
1336
1336
  void Init_generator(void)
1337
1337
  {
1338
+ #undef rb_intern
1338
1339
  rb_require("json/common");
1339
1340
 
1340
1341
  mJSON = rb_define_module("JSON");
@@ -91,19 +91,20 @@ static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
91
91
 
92
92
  static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
93
93
  static VALUE CNaN, CInfinity, CMinusInfinity;
94
+ static VALUE cBigDecimal = Qundef;
94
95
 
95
96
  static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
96
97
  i_chr, i_max_nesting, i_allow_nan, i_symbolize_names,
97
98
  i_object_class, i_array_class, i_decimal_class, i_key_p,
98
99
  i_deep_const_get, i_match, i_match_string, i_aset, i_aref,
99
- i_leftshift, i_new;
100
+ i_leftshift, i_new, i_BigDecimal;
100
101
 
101
102
 
102
- #line 125 "parser.rl"
103
+ #line 126 "parser.rl"
103
104
 
104
105
 
105
106
 
106
- #line 107 "parser.c"
107
+ #line 108 "parser.c"
107
108
  enum {JSON_object_start = 1};
108
109
  enum {JSON_object_first_final = 27};
109
110
  enum {JSON_object_error = 0};
@@ -111,7 +112,7 @@ enum {JSON_object_error = 0};
111
112
  enum {JSON_object_en_main = 1};
112
113
 
113
114
 
114
- #line 166 "parser.rl"
115
+ #line 167 "parser.rl"
115
116
 
116
117
 
117
118
  static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -127,14 +128,14 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
127
128
  *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
128
129
 
129
130
 
130
- #line 131 "parser.c"
131
+ #line 132 "parser.c"
131
132
  {
132
133
  cs = JSON_object_start;
133
134
  }
134
135
 
135
- #line 181 "parser.rl"
136
+ #line 182 "parser.rl"
136
137
 
137
- #line 138 "parser.c"
138
+ #line 139 "parser.c"
138
139
  {
139
140
  if ( p == pe )
140
141
  goto _test_eof;
@@ -162,7 +163,7 @@ case 2:
162
163
  goto st2;
163
164
  goto st0;
164
165
  tr2:
165
- #line 148 "parser.rl"
166
+ #line 149 "parser.rl"
166
167
  {
167
168
  char *np;
168
169
  json->parsing_name = 1;
@@ -175,7 +176,7 @@ st3:
175
176
  if ( ++p == pe )
176
177
  goto _test_eof3;
177
178
  case 3:
178
- #line 179 "parser.c"
179
+ #line 180 "parser.c"
179
180
  switch( (*p) ) {
180
181
  case 13: goto st3;
181
182
  case 32: goto st3;
@@ -242,7 +243,7 @@ case 8:
242
243
  goto st8;
243
244
  goto st0;
244
245
  tr11:
245
- #line 133 "parser.rl"
246
+ #line 134 "parser.rl"
246
247
  {
247
248
  VALUE v = Qnil;
248
249
  char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
@@ -262,7 +263,7 @@ st9:
262
263
  if ( ++p == pe )
263
264
  goto _test_eof9;
264
265
  case 9:
265
- #line 266 "parser.c"
266
+ #line 267 "parser.c"
266
267
  switch( (*p) ) {
267
268
  case 13: goto st9;
268
269
  case 32: goto st9;
@@ -351,14 +352,14 @@ case 18:
351
352
  goto st9;
352
353
  goto st18;
353
354
  tr4:
354
- #line 156 "parser.rl"
355
+ #line 157 "parser.rl"
355
356
  { p--; {p++; cs = 27; goto _out;} }
356
357
  goto st27;
357
358
  st27:
358
359
  if ( ++p == pe )
359
360
  goto _test_eof27;
360
361
  case 27:
361
- #line 362 "parser.c"
362
+ #line 363 "parser.c"
362
363
  goto st0;
363
364
  st19:
364
365
  if ( ++p == pe )
@@ -456,7 +457,7 @@ case 26:
456
457
  _out: {}
457
458
  }
458
459
 
459
- #line 182 "parser.rl"
460
+ #line 183 "parser.rl"
460
461
 
461
462
  if (cs >= JSON_object_first_final) {
462
463
  if (json->create_additions) {
@@ -481,7 +482,7 @@ case 26:
481
482
 
482
483
 
483
484
 
484
- #line 485 "parser.c"
485
+ #line 486 "parser.c"
485
486
  enum {JSON_value_start = 1};
486
487
  enum {JSON_value_first_final = 29};
487
488
  enum {JSON_value_error = 0};
@@ -489,7 +490,7 @@ enum {JSON_value_error = 0};
489
490
  enum {JSON_value_en_main = 1};
490
491
 
491
492
 
492
- #line 282 "parser.rl"
493
+ #line 283 "parser.rl"
493
494
 
494
495
 
495
496
  static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -497,14 +498,14 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
497
498
  int cs = EVIL;
498
499
 
499
500
 
500
- #line 501 "parser.c"
501
+ #line 502 "parser.c"
501
502
  {
502
503
  cs = JSON_value_start;
503
504
  }
504
505
 
505
- #line 289 "parser.rl"
506
+ #line 290 "parser.rl"
506
507
 
507
- #line 508 "parser.c"
508
+ #line 509 "parser.c"
508
509
  {
509
510
  if ( p == pe )
510
511
  goto _test_eof;
@@ -538,14 +539,14 @@ st0:
538
539
  cs = 0;
539
540
  goto _out;
540
541
  tr2:
541
- #line 234 "parser.rl"
542
+ #line 235 "parser.rl"
542
543
  {
543
544
  char *np = JSON_parse_string(json, p, pe, result);
544
545
  if (np == NULL) { p--; {p++; cs = 29; goto _out;} } else {p = (( np))-1;}
545
546
  }
546
547
  goto st29;
547
548
  tr3:
548
- #line 239 "parser.rl"
549
+ #line 240 "parser.rl"
549
550
  {
550
551
  char *np;
551
552
  if(pe > p + 8 && !strncmp(MinusInfinity, p, 9)) {
@@ -565,7 +566,7 @@ tr3:
565
566
  }
566
567
  goto st29;
567
568
  tr7:
568
- #line 257 "parser.rl"
569
+ #line 258 "parser.rl"
569
570
  {
570
571
  char *np;
571
572
  np = JSON_parse_array(json, p, pe, result, current_nesting + 1);
@@ -573,7 +574,7 @@ tr7:
573
574
  }
574
575
  goto st29;
575
576
  tr11:
576
- #line 263 "parser.rl"
577
+ #line 264 "parser.rl"
577
578
  {
578
579
  char *np;
579
580
  np = JSON_parse_object(json, p, pe, result, current_nesting + 1);
@@ -581,7 +582,7 @@ tr11:
581
582
  }
582
583
  goto st29;
583
584
  tr25:
584
- #line 227 "parser.rl"
585
+ #line 228 "parser.rl"
585
586
  {
586
587
  if (json->allow_nan) {
587
588
  *result = CInfinity;
@@ -591,7 +592,7 @@ tr25:
591
592
  }
592
593
  goto st29;
593
594
  tr27:
594
- #line 220 "parser.rl"
595
+ #line 221 "parser.rl"
595
596
  {
596
597
  if (json->allow_nan) {
597
598
  *result = CNaN;
@@ -601,19 +602,19 @@ tr27:
601
602
  }
602
603
  goto st29;
603
604
  tr31:
604
- #line 214 "parser.rl"
605
+ #line 215 "parser.rl"
605
606
  {
606
607
  *result = Qfalse;
607
608
  }
608
609
  goto st29;
609
610
  tr34:
610
- #line 211 "parser.rl"
611
+ #line 212 "parser.rl"
611
612
  {
612
613
  *result = Qnil;
613
614
  }
614
615
  goto st29;
615
616
  tr37:
616
- #line 217 "parser.rl"
617
+ #line 218 "parser.rl"
617
618
  {
618
619
  *result = Qtrue;
619
620
  }
@@ -622,9 +623,9 @@ st29:
622
623
  if ( ++p == pe )
623
624
  goto _test_eof29;
624
625
  case 29:
625
- #line 269 "parser.rl"
626
+ #line 270 "parser.rl"
626
627
  { p--; {p++; cs = 29; goto _out;} }
627
- #line 628 "parser.c"
628
+ #line 629 "parser.c"
628
629
  switch( (*p) ) {
629
630
  case 13: goto st29;
630
631
  case 32: goto st29;
@@ -865,7 +866,7 @@ case 28:
865
866
  _out: {}
866
867
  }
867
868
 
868
- #line 290 "parser.rl"
869
+ #line 291 "parser.rl"
869
870
 
870
871
  if (cs >= JSON_value_first_final) {
871
872
  return p;
@@ -875,7 +876,7 @@ case 28:
875
876
  }
876
877
 
877
878
 
878
- #line 879 "parser.c"
879
+ #line 880 "parser.c"
879
880
  enum {JSON_integer_start = 1};
880
881
  enum {JSON_integer_first_final = 3};
881
882
  enum {JSON_integer_error = 0};
@@ -883,7 +884,7 @@ enum {JSON_integer_error = 0};
883
884
  enum {JSON_integer_en_main = 1};
884
885
 
885
886
 
886
- #line 306 "parser.rl"
887
+ #line 307 "parser.rl"
887
888
 
888
889
 
889
890
  static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
@@ -891,15 +892,15 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res
891
892
  int cs = EVIL;
892
893
 
893
894
 
894
- #line 895 "parser.c"
895
+ #line 896 "parser.c"
895
896
  {
896
897
  cs = JSON_integer_start;
897
898
  }
898
899
 
899
- #line 313 "parser.rl"
900
+ #line 314 "parser.rl"
900
901
  json->memo = p;
901
902
 
902
- #line 903 "parser.c"
903
+ #line 904 "parser.c"
903
904
  {
904
905
  if ( p == pe )
905
906
  goto _test_eof;
@@ -933,14 +934,14 @@ case 3:
933
934
  goto st0;
934
935
  goto tr4;
935
936
  tr4:
936
- #line 303 "parser.rl"
937
+ #line 304 "parser.rl"
937
938
  { p--; {p++; cs = 4; goto _out;} }
938
939
  goto st4;
939
940
  st4:
940
941
  if ( ++p == pe )
941
942
  goto _test_eof4;
942
943
  case 4:
943
- #line 944 "parser.c"
944
+ #line 945 "parser.c"
944
945
  goto st0;
945
946
  st5:
946
947
  if ( ++p == pe )
@@ -959,7 +960,7 @@ case 5:
959
960
  _out: {}
960
961
  }
961
962
 
962
- #line 315 "parser.rl"
963
+ #line 316 "parser.rl"
963
964
 
964
965
  if (cs >= JSON_integer_first_final) {
965
966
  long len = p - json->memo;
@@ -974,7 +975,7 @@ case 5:
974
975
  }
975
976
 
976
977
 
977
- #line 978 "parser.c"
978
+ #line 979 "parser.c"
978
979
  enum {JSON_float_start = 1};
979
980
  enum {JSON_float_first_final = 8};
980
981
  enum {JSON_float_error = 0};
@@ -982,23 +983,36 @@ enum {JSON_float_error = 0};
982
983
  enum {JSON_float_en_main = 1};
983
984
 
984
985
 
985
- #line 340 "parser.rl"
986
+ #line 341 "parser.rl"
987
+
986
988
 
989
+ static int is_bigdecimal_class(VALUE obj)
990
+ {
991
+ if (cBigDecimal == Qundef) {
992
+ if (rb_const_defined(rb_cObject, i_BigDecimal)) {
993
+ cBigDecimal = rb_const_get_at(rb_cObject, i_BigDecimal);
994
+ }
995
+ else {
996
+ return 0;
997
+ }
998
+ }
999
+ return obj == cBigDecimal;
1000
+ }
987
1001
 
988
1002
  static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
989
1003
  {
990
1004
  int cs = EVIL;
991
1005
 
992
1006
 
993
- #line 994 "parser.c"
1007
+ #line 1008 "parser.c"
994
1008
  {
995
1009
  cs = JSON_float_start;
996
1010
  }
997
1011
 
998
- #line 347 "parser.rl"
1012
+ #line 361 "parser.rl"
999
1013
  json->memo = p;
1000
1014
 
1001
- #line 1002 "parser.c"
1015
+ #line 1016 "parser.c"
1002
1016
  {
1003
1017
  if ( p == pe )
1004
1018
  goto _test_eof;
@@ -1056,14 +1070,14 @@ case 8:
1056
1070
  goto st0;
1057
1071
  goto tr9;
1058
1072
  tr9:
1059
- #line 334 "parser.rl"
1073
+ #line 335 "parser.rl"
1060
1074
  { p--; {p++; cs = 9; goto _out;} }
1061
1075
  goto st9;
1062
1076
  st9:
1063
1077
  if ( ++p == pe )
1064
1078
  goto _test_eof9;
1065
1079
  case 9:
1066
- #line 1067 "parser.c"
1080
+ #line 1081 "parser.c"
1067
1081
  goto st0;
1068
1082
  st5:
1069
1083
  if ( ++p == pe )
@@ -1124,7 +1138,7 @@ case 7:
1124
1138
  _out: {}
1125
1139
  }
1126
1140
 
1127
- #line 349 "parser.rl"
1141
+ #line 363 "parser.rl"
1128
1142
 
1129
1143
  if (cs >= JSON_float_first_final) {
1130
1144
  long len = p - json->memo;
@@ -1136,7 +1150,11 @@ case 7:
1136
1150
  } else {
1137
1151
  VALUE text;
1138
1152
  text = rb_str_new2(FBUFFER_PTR(json->fbuffer));
1139
- *result = rb_funcall(json->decimal_class, i_new, 1, text);
1153
+ if (is_bigdecimal_class(json->decimal_class)) {
1154
+ *result = rb_funcall(Qnil, i_BigDecimal, 1, text);
1155
+ } else {
1156
+ *result = rb_funcall(json->decimal_class, i_new, 1, text);
1157
+ }
1140
1158
  }
1141
1159
  return p + 1;
1142
1160
  } else {
@@ -1146,7 +1164,7 @@ case 7:
1146
1164
 
1147
1165
 
1148
1166
 
1149
- #line 1150 "parser.c"
1167
+ #line 1168 "parser.c"
1150
1168
  enum {JSON_array_start = 1};
1151
1169
  enum {JSON_array_first_final = 17};
1152
1170
  enum {JSON_array_error = 0};
@@ -1154,7 +1172,7 @@ enum {JSON_array_error = 0};
1154
1172
  enum {JSON_array_en_main = 1};
1155
1173
 
1156
1174
 
1157
- #line 398 "parser.rl"
1175
+ #line 416 "parser.rl"
1158
1176
 
1159
1177
 
1160
1178
  static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
@@ -1168,14 +1186,14 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul
1168
1186
  *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
1169
1187
 
1170
1188
 
1171
- #line 1172 "parser.c"
1189
+ #line 1190 "parser.c"
1172
1190
  {
1173
1191
  cs = JSON_array_start;
1174
1192
  }
1175
1193
 
1176
- #line 411 "parser.rl"
1194
+ #line 429 "parser.rl"
1177
1195
 
1178
- #line 1179 "parser.c"
1196
+ #line 1197 "parser.c"
1179
1197
  {
1180
1198
  if ( p == pe )
1181
1199
  goto _test_eof;
@@ -1214,7 +1232,7 @@ case 2:
1214
1232
  goto st2;
1215
1233
  goto st0;
1216
1234
  tr2:
1217
- #line 375 "parser.rl"
1235
+ #line 393 "parser.rl"
1218
1236
  {
1219
1237
  VALUE v = Qnil;
1220
1238
  char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
@@ -1234,7 +1252,7 @@ st3:
1234
1252
  if ( ++p == pe )
1235
1253
  goto _test_eof3;
1236
1254
  case 3:
1237
- #line 1238 "parser.c"
1255
+ #line 1256 "parser.c"
1238
1256
  switch( (*p) ) {
1239
1257
  case 13: goto st3;
1240
1258
  case 32: goto st3;
@@ -1334,14 +1352,14 @@ case 12:
1334
1352
  goto st3;
1335
1353
  goto st12;
1336
1354
  tr4:
1337
- #line 390 "parser.rl"
1355
+ #line 408 "parser.rl"
1338
1356
  { p--; {p++; cs = 17; goto _out;} }
1339
1357
  goto st17;
1340
1358
  st17:
1341
1359
  if ( ++p == pe )
1342
1360
  goto _test_eof17;
1343
1361
  case 17:
1344
- #line 1345 "parser.c"
1362
+ #line 1363 "parser.c"
1345
1363
  goto st0;
1346
1364
  st13:
1347
1365
  if ( ++p == pe )
@@ -1397,7 +1415,7 @@ case 16:
1397
1415
  _out: {}
1398
1416
  }
1399
1417
 
1400
- #line 412 "parser.rl"
1418
+ #line 430 "parser.rl"
1401
1419
 
1402
1420
  if(cs >= JSON_array_first_final) {
1403
1421
  return p + 1;
@@ -1486,7 +1504,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
1486
1504
  }
1487
1505
 
1488
1506
 
1489
- #line 1490 "parser.c"
1507
+ #line 1508 "parser.c"
1490
1508
  enum {JSON_string_start = 1};
1491
1509
  enum {JSON_string_first_final = 8};
1492
1510
  enum {JSON_string_error = 0};
@@ -1494,7 +1512,7 @@ enum {JSON_string_error = 0};
1494
1512
  enum {JSON_string_en_main = 1};
1495
1513
 
1496
1514
 
1497
- #line 519 "parser.rl"
1515
+ #line 537 "parser.rl"
1498
1516
 
1499
1517
 
1500
1518
  static int
@@ -1516,15 +1534,15 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
1516
1534
 
1517
1535
  *result = rb_str_buf_new(0);
1518
1536
 
1519
- #line 1520 "parser.c"
1537
+ #line 1538 "parser.c"
1520
1538
  {
1521
1539
  cs = JSON_string_start;
1522
1540
  }
1523
1541
 
1524
- #line 540 "parser.rl"
1542
+ #line 558 "parser.rl"
1525
1543
  json->memo = p;
1526
1544
 
1527
- #line 1528 "parser.c"
1545
+ #line 1546 "parser.c"
1528
1546
  {
1529
1547
  if ( p == pe )
1530
1548
  goto _test_eof;
@@ -1549,7 +1567,7 @@ case 2:
1549
1567
  goto st0;
1550
1568
  goto st2;
1551
1569
  tr2:
1552
- #line 505 "parser.rl"
1570
+ #line 523 "parser.rl"
1553
1571
  {
1554
1572
  *result = json_string_unescape(*result, json->memo + 1, p);
1555
1573
  if (NIL_P(*result)) {
@@ -1560,14 +1578,14 @@ tr2:
1560
1578
  {p = (( p + 1))-1;}
1561
1579
  }
1562
1580
  }
1563
- #line 516 "parser.rl"
1581
+ #line 534 "parser.rl"
1564
1582
  { p--; {p++; cs = 8; goto _out;} }
1565
1583
  goto st8;
1566
1584
  st8:
1567
1585
  if ( ++p == pe )
1568
1586
  goto _test_eof8;
1569
1587
  case 8:
1570
- #line 1571 "parser.c"
1588
+ #line 1589 "parser.c"
1571
1589
  goto st0;
1572
1590
  st3:
1573
1591
  if ( ++p == pe )
@@ -1643,7 +1661,7 @@ case 7:
1643
1661
  _out: {}
1644
1662
  }
1645
1663
 
1646
- #line 542 "parser.rl"
1664
+ #line 560 "parser.rl"
1647
1665
 
1648
1666
  if (json->create_additions && RTEST(match_string = json->match_string)) {
1649
1667
  VALUE klass;
@@ -1659,7 +1677,9 @@ case 7:
1659
1677
  if (json->symbolize_names && json->parsing_name) {
1660
1678
  *result = rb_str_intern(*result);
1661
1679
  } else {
1662
- rb_str_resize(*result, RSTRING_LEN(*result));
1680
+ if (RB_TYPE_P(*result, T_STRING)) {
1681
+ rb_str_resize(*result, RSTRING_LEN(*result));
1682
+ }
1663
1683
  }
1664
1684
  if (cs >= JSON_string_first_final) {
1665
1685
  return p + 1;
@@ -1830,7 +1850,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
1830
1850
  }
1831
1851
 
1832
1852
 
1833
- #line 1834 "parser.c"
1853
+ #line 1854 "parser.c"
1834
1854
  enum {JSON_start = 1};
1835
1855
  enum {JSON_first_final = 10};
1836
1856
  enum {JSON_error = 0};
@@ -1838,7 +1858,7 @@ enum {JSON_error = 0};
1838
1858
  enum {JSON_en_main = 1};
1839
1859
 
1840
1860
 
1841
- #line 742 "parser.rl"
1861
+ #line 762 "parser.rl"
1842
1862
 
1843
1863
 
1844
1864
  /*
@@ -1855,16 +1875,16 @@ static VALUE cParser_parse(VALUE self)
1855
1875
  GET_PARSER;
1856
1876
 
1857
1877
 
1858
- #line 1859 "parser.c"
1878
+ #line 1879 "parser.c"
1859
1879
  {
1860
1880
  cs = JSON_start;
1861
1881
  }
1862
1882
 
1863
- #line 758 "parser.rl"
1883
+ #line 778 "parser.rl"
1864
1884
  p = json->source;
1865
1885
  pe = p + json->len;
1866
1886
 
1867
- #line 1868 "parser.c"
1887
+ #line 1888 "parser.c"
1868
1888
  {
1869
1889
  if ( p == pe )
1870
1890
  goto _test_eof;
@@ -1898,7 +1918,7 @@ st0:
1898
1918
  cs = 0;
1899
1919
  goto _out;
1900
1920
  tr2:
1901
- #line 734 "parser.rl"
1921
+ #line 754 "parser.rl"
1902
1922
  {
1903
1923
  char *np = JSON_parse_value(json, p, pe, &result, 0);
1904
1924
  if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
@@ -1908,7 +1928,7 @@ st10:
1908
1928
  if ( ++p == pe )
1909
1929
  goto _test_eof10;
1910
1930
  case 10:
1911
- #line 1912 "parser.c"
1931
+ #line 1932 "parser.c"
1912
1932
  switch( (*p) ) {
1913
1933
  case 13: goto st10;
1914
1934
  case 32: goto st10;
@@ -1997,7 +2017,7 @@ case 9:
1997
2017
  _out: {}
1998
2018
  }
1999
2019
 
2000
- #line 761 "parser.rl"
2020
+ #line 781 "parser.rl"
2001
2021
 
2002
2022
  if (cs >= JSON_first_final && p == pe) {
2003
2023
  return result;
@@ -2064,6 +2084,7 @@ static VALUE cParser_source(VALUE self)
2064
2084
 
2065
2085
  void Init_parser(void)
2066
2086
  {
2087
+ #undef rb_intern
2067
2088
  rb_require("json/common");
2068
2089
  mJSON = rb_define_module("JSON");
2069
2090
  mExt = rb_define_module_under(mJSON, "Ext");
@@ -2098,6 +2119,7 @@ void Init_parser(void)
2098
2119
  i_aref = rb_intern("[]");
2099
2120
  i_leftshift = rb_intern("<<");
2100
2121
  i_new = rb_intern("new");
2122
+ i_BigDecimal = rb_intern("BigDecimal");
2101
2123
  }
2102
2124
 
2103
2125
  /*