oj 3.13.8 → 3.13.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/ext/oj/mimic_json.c +1 -10
- data/ext/oj/oj.c +108 -152
- data/ext/oj/oj.h +1 -0
- data/lib/oj/version.rb +1 -1
- data/test/foo.rb +12 -6
- 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: 646e1253e68f33e284b1efa4ec5f6c3ad9de2e52a1f4ddfbb37435ceb5e23bd0
|
4
|
+
data.tar.gz: 775d9f0169d77a6f06990cf0d1f0e1904a530567d0939471f326e7ec5ee24c37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f15a8a5dabfece0fb92ebfd2be99d567890441a2774c361646fc0ab03eba1de0070106cdc0addcc6fa75cf797dcd568b2f0129954c5debbe9ffa334ea8aa7fc4
|
7
|
+
data.tar.gz: 9d3d0d399610c5209a6819df7583368c14250311249ff3f42a67c868057b96fb8f89c12657aeaf36f1ef545793038aece84f8a7524f40f77ed8636fe6d9e09f5
|
data/CHANGELOG.md
CHANGED
data/ext/oj/mimic_json.c
CHANGED
@@ -6,8 +6,6 @@
|
|
6
6
|
#include "oj.h"
|
7
7
|
#include "parse.h"
|
8
8
|
|
9
|
-
static VALUE symbolize_names_sym = Qundef;
|
10
|
-
|
11
9
|
extern const char oj_json_class[];
|
12
10
|
|
13
11
|
VALUE oj_array_nl_sym;
|
@@ -531,11 +529,7 @@ static VALUE mimic_parse_core(int argc, VALUE *argv, VALUE self, bool bang) {
|
|
531
529
|
if (T_HASH != rb_type(ropts)) {
|
532
530
|
rb_raise(rb_eArgError, "options must be a hash.");
|
533
531
|
}
|
534
|
-
if (
|
535
|
-
symbolize_names_sym = ID2SYM(rb_intern("symbolize_names"));
|
536
|
-
rb_gc_register_address(&symbolize_names_sym);
|
537
|
-
}
|
538
|
-
if (Qnil != (v = rb_hash_lookup(ropts, symbolize_names_sym))) {
|
532
|
+
if (Qnil != (v = rb_hash_lookup(ropts, oj_symbolize_names_sym))) {
|
539
533
|
pi.options.sym_key = (Qtrue == v) ? Yes : No;
|
540
534
|
}
|
541
535
|
if (Qnil != (v = rb_hash_lookup(ropts, oj_quirks_mode_sym))) {
|
@@ -852,9 +846,6 @@ void oj_mimic_json_methods(VALUE json) {
|
|
852
846
|
// Pull in the JSON::State mimic file.
|
853
847
|
state_class = rb_const_get_at(generator, rb_intern("State"));
|
854
848
|
rb_gc_register_mark_object(state_class);
|
855
|
-
|
856
|
-
symbolize_names_sym = ID2SYM(rb_intern("symbolize_names"));
|
857
|
-
rb_gc_register_address(&symbolize_names_sym);
|
858
849
|
}
|
859
850
|
|
860
851
|
/* Document-module: JSON
|
data/ext/oj/oj.c
CHANGED
@@ -94,6 +94,7 @@ VALUE oj_indent_sym;
|
|
94
94
|
VALUE oj_object_class_sym;
|
95
95
|
VALUE oj_quirks_mode_sym;
|
96
96
|
VALUE oj_safe_sym;
|
97
|
+
VALUE oj_symbolize_names_sym;
|
97
98
|
VALUE oj_trace_sym;
|
98
99
|
|
99
100
|
static VALUE allow_blank_sym;
|
@@ -308,106 +309,76 @@ static VALUE get_def_opts(VALUE self) {
|
|
308
309
|
rb_hash_aset(opts, sec_prec_sym, INT2FIX(oj_default_options.sec_prec));
|
309
310
|
rb_hash_aset(opts,
|
310
311
|
circular_sym,
|
311
|
-
(Yes == oj_default_options.circular)
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
auto_define_sym,
|
321
|
-
(Yes == oj_default_options.auto_define)
|
322
|
-
? Qtrue
|
323
|
-
: ((No == oj_default_options.auto_define) ? Qfalse : Qnil));
|
312
|
+
(Yes == oj_default_options.circular) ? Qtrue : ((No == oj_default_options.circular) ? Qfalse : Qnil));
|
313
|
+
rb_hash_aset(
|
314
|
+
opts,
|
315
|
+
class_cache_sym,
|
316
|
+
(Yes == oj_default_options.class_cache) ? Qtrue : ((No == oj_default_options.class_cache) ? Qfalse : Qnil));
|
317
|
+
rb_hash_aset(
|
318
|
+
opts,
|
319
|
+
auto_define_sym,
|
320
|
+
(Yes == oj_default_options.auto_define) ? Qtrue : ((No == oj_default_options.auto_define) ? Qfalse : Qnil));
|
324
321
|
rb_hash_aset(opts,
|
325
322
|
symbol_keys_sym,
|
326
|
-
(Yes == oj_default_options.sym_key)
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
oj_create_additions_sym,
|
336
|
-
(Yes == oj_default_options.create_ok)
|
337
|
-
? Qtrue
|
338
|
-
: ((No == oj_default_options.create_ok) ? Qfalse : Qnil));
|
323
|
+
(Yes == oj_default_options.sym_key) ? Qtrue : ((No == oj_default_options.sym_key) ? Qfalse : Qnil));
|
324
|
+
rb_hash_aset(
|
325
|
+
opts,
|
326
|
+
bigdecimal_as_decimal_sym,
|
327
|
+
(Yes == oj_default_options.bigdec_as_num) ? Qtrue : ((No == oj_default_options.bigdec_as_num) ? Qfalse : Qnil));
|
328
|
+
rb_hash_aset(
|
329
|
+
opts,
|
330
|
+
oj_create_additions_sym,
|
331
|
+
(Yes == oj_default_options.create_ok) ? Qtrue : ((No == oj_default_options.create_ok) ? Qfalse : Qnil));
|
339
332
|
rb_hash_aset(opts,
|
340
333
|
use_to_json_sym,
|
341
|
-
(Yes == oj_default_options.to_json)
|
342
|
-
? Qtrue
|
343
|
-
: ((No == oj_default_options.to_json) ? Qfalse : Qnil));
|
334
|
+
(Yes == oj_default_options.to_json) ? Qtrue : ((No == oj_default_options.to_json) ? Qfalse : Qnil));
|
344
335
|
rb_hash_aset(opts,
|
345
336
|
use_to_hash_sym,
|
346
|
-
(Yes == oj_default_options.to_hash)
|
347
|
-
? Qtrue
|
348
|
-
: ((No == oj_default_options.to_hash) ? Qfalse : Qnil));
|
337
|
+
(Yes == oj_default_options.to_hash) ? Qtrue : ((No == oj_default_options.to_hash) ? Qfalse : Qnil));
|
349
338
|
rb_hash_aset(opts,
|
350
339
|
use_as_json_sym,
|
351
|
-
(Yes == oj_default_options.as_json)
|
352
|
-
? Qtrue
|
353
|
-
: ((No == oj_default_options.as_json) ? Qfalse : Qnil));
|
340
|
+
(Yes == oj_default_options.as_json) ? Qtrue : ((No == oj_default_options.as_json) ? Qfalse : Qnil));
|
354
341
|
rb_hash_aset(opts,
|
355
342
|
use_raw_json_sym,
|
356
|
-
(Yes == oj_default_options.raw_json)
|
357
|
-
? Qtrue
|
358
|
-
: ((No == oj_default_options.raw_json) ? Qfalse : Qnil));
|
343
|
+
(Yes == oj_default_options.raw_json) ? Qtrue : ((No == oj_default_options.raw_json) ? Qfalse : Qnil));
|
359
344
|
rb_hash_aset(opts,
|
360
345
|
nilnil_sym,
|
361
|
-
(Yes == oj_default_options.nilnil)
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
(Yes == oj_default_options.empty_string)
|
367
|
-
? Qtrue
|
368
|
-
: ((No == oj_default_options.empty_string) ? Qfalse : Qnil));
|
346
|
+
(Yes == oj_default_options.nilnil) ? Qtrue : ((No == oj_default_options.nilnil) ? Qfalse : Qnil));
|
347
|
+
rb_hash_aset(
|
348
|
+
opts,
|
349
|
+
empty_string_sym,
|
350
|
+
(Yes == oj_default_options.empty_string) ? Qtrue : ((No == oj_default_options.empty_string) ? Qfalse : Qnil));
|
369
351
|
rb_hash_aset(opts,
|
370
352
|
allow_gc_sym,
|
371
|
-
(Yes == oj_default_options.allow_gc)
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
rb_hash_aset(opts,
|
385
|
-
oj_allow_nan_sym,
|
386
|
-
(Yes == oj_default_options.allow_nan)
|
387
|
-
? Qtrue
|
388
|
-
: ((No == oj_default_options.allow_nan) ? Qfalse : Qnil));
|
353
|
+
(Yes == oj_default_options.allow_gc) ? Qtrue : ((No == oj_default_options.allow_gc) ? Qfalse : Qnil));
|
354
|
+
rb_hash_aset(
|
355
|
+
opts,
|
356
|
+
oj_quirks_mode_sym,
|
357
|
+
(Yes == oj_default_options.quirks_mode) ? Qtrue : ((No == oj_default_options.quirks_mode) ? Qfalse : Qnil));
|
358
|
+
rb_hash_aset(
|
359
|
+
opts,
|
360
|
+
allow_invalid_unicode_sym,
|
361
|
+
(Yes == oj_default_options.allow_invalid) ? Qtrue : ((No == oj_default_options.allow_invalid) ? Qfalse : Qnil));
|
362
|
+
rb_hash_aset(
|
363
|
+
opts,
|
364
|
+
oj_allow_nan_sym,
|
365
|
+
(Yes == oj_default_options.allow_nan) ? Qtrue : ((No == oj_default_options.allow_nan) ? Qfalse : Qnil));
|
389
366
|
rb_hash_aset(opts,
|
390
367
|
oj_trace_sym,
|
391
|
-
(Yes == oj_default_options.trace)
|
392
|
-
? Qtrue
|
393
|
-
: ((No == oj_default_options.trace) ? Qfalse : Qnil));
|
368
|
+
(Yes == oj_default_options.trace) ? Qtrue : ((No == oj_default_options.trace) ? Qfalse : Qnil));
|
394
369
|
rb_hash_aset(opts,
|
395
370
|
oj_safe_sym,
|
396
|
-
(Yes == oj_default_options.safe)
|
397
|
-
? Qtrue
|
398
|
-
: ((No == oj_default_options.safe) ? Qfalse : Qnil));
|
371
|
+
(Yes == oj_default_options.safe) ? Qtrue : ((No == oj_default_options.safe) ? Qfalse : Qnil));
|
399
372
|
rb_hash_aset(opts, float_prec_sym, INT2FIX(oj_default_options.float_prec));
|
400
373
|
rb_hash_aset(opts, cache_str_sym, INT2FIX(oj_default_options.cache_str));
|
401
|
-
rb_hash_aset(
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
? Qtrue
|
410
|
-
: ((No == oj_default_options.cache_keys) ? Qfalse : Qnil));
|
374
|
+
rb_hash_aset(
|
375
|
+
opts,
|
376
|
+
ignore_under_sym,
|
377
|
+
(Yes == oj_default_options.ignore_under) ? Qtrue : ((No == oj_default_options.ignore_under) ? Qfalse : Qnil));
|
378
|
+
rb_hash_aset(
|
379
|
+
opts,
|
380
|
+
cache_keys_sym,
|
381
|
+
(Yes == oj_default_options.cache_keys) ? Qtrue : ((No == oj_default_options.cache_keys) ? Qfalse : Qnil));
|
411
382
|
switch (oj_default_options.mode) {
|
412
383
|
case StrictMode: rb_hash_aset(opts, mode_sym, strict_sym); break;
|
413
384
|
case CompatMode: rb_hash_aset(opts, mode_sym, compat_sym); break;
|
@@ -453,30 +424,25 @@ static VALUE get_def_opts(VALUE self) {
|
|
453
424
|
default: rb_hash_aset(opts, bigdecimal_load_sym, auto_sym); break;
|
454
425
|
}
|
455
426
|
rb_hash_aset(opts, compat_bigdecimal_sym, oj_default_options.compat_bigdec ? Qtrue : Qfalse);
|
427
|
+
rb_hash_aset(opts,
|
428
|
+
create_id_sym,
|
429
|
+
(NULL == oj_default_options.create_id) ? Qnil : rb_str_new2(oj_default_options.create_id));
|
456
430
|
rb_hash_aset(
|
457
431
|
opts,
|
458
|
-
|
459
|
-
(
|
460
|
-
rb_hash_aset(
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
(0 == oj_default_options.dump_opts.hash_size)
|
473
|
-
? Qnil
|
474
|
-
: rb_str_new2(oj_default_options.dump_opts.hash_nl));
|
475
|
-
rb_hash_aset(opts,
|
476
|
-
oj_array_nl_sym,
|
477
|
-
(0 == oj_default_options.dump_opts.array_size)
|
478
|
-
? Qnil
|
479
|
-
: rb_str_new2(oj_default_options.dump_opts.array_nl));
|
432
|
+
oj_space_sym,
|
433
|
+
(0 == oj_default_options.dump_opts.after_size) ? Qnil : rb_str_new2(oj_default_options.dump_opts.after_sep));
|
434
|
+
rb_hash_aset(
|
435
|
+
opts,
|
436
|
+
oj_space_before_sym,
|
437
|
+
(0 == oj_default_options.dump_opts.before_size) ? Qnil : rb_str_new2(oj_default_options.dump_opts.before_sep));
|
438
|
+
rb_hash_aset(
|
439
|
+
opts,
|
440
|
+
oj_object_nl_sym,
|
441
|
+
(0 == oj_default_options.dump_opts.hash_size) ? Qnil : rb_str_new2(oj_default_options.dump_opts.hash_nl));
|
442
|
+
rb_hash_aset(
|
443
|
+
opts,
|
444
|
+
oj_array_nl_sym,
|
445
|
+
(0 == oj_default_options.dump_opts.array_size) ? Qnil : rb_str_new2(oj_default_options.dump_opts.array_nl));
|
480
446
|
|
481
447
|
switch (oj_default_options.dump_opts.nan_dump) {
|
482
448
|
case NullNan: rb_hash_aset(opts, nan_sym, null_sym); break;
|
@@ -584,16 +550,14 @@ static VALUE set_def_opts(VALUE self, VALUE opts) {
|
|
584
550
|
return Qnil;
|
585
551
|
}
|
586
552
|
|
587
|
-
bool oj_hash_has_key(VALUE hash, VALUE key)
|
588
|
-
{
|
553
|
+
bool oj_hash_has_key(VALUE hash, VALUE key) {
|
589
554
|
if (Qundef == rb_hash_lookup2(hash, key, Qundef)) {
|
590
555
|
return false;
|
591
556
|
}
|
592
557
|
return true;
|
593
558
|
}
|
594
559
|
|
595
|
-
bool set_yesno_options(VALUE key, VALUE value, Options copts)
|
596
|
-
{
|
560
|
+
bool set_yesno_options(VALUE key, VALUE value, Options copts) {
|
597
561
|
struct _yesNoOpt ynos[] = {{circular_sym, &copts->circular},
|
598
562
|
{auto_define_sym, &copts->auto_define},
|
599
563
|
{symbol_keys_sym, &copts->sym_key},
|
@@ -616,29 +580,26 @@ bool set_yesno_options(VALUE key, VALUE value, Options copts)
|
|
616
580
|
{oj_create_additions_sym, &copts->create_ok},
|
617
581
|
{cache_keys_sym, &copts->cache_keys},
|
618
582
|
{Qnil, 0}};
|
619
|
-
YesNoOpt
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
}
|
636
|
-
}
|
583
|
+
YesNoOpt o;
|
584
|
+
|
585
|
+
for (o = ynos; 0 != o->attr; o++) {
|
586
|
+
if (key == o->sym) {
|
587
|
+
if (Qnil == value) {
|
588
|
+
*o->attr = NotSet;
|
589
|
+
} else if (Qtrue == value) {
|
590
|
+
*o->attr = Yes;
|
591
|
+
} else if (Qfalse == value) {
|
592
|
+
*o->attr = No;
|
593
|
+
} else {
|
594
|
+
rb_raise(rb_eArgError, "%s must be true, false, or nil.", rb_id2name(key));
|
595
|
+
}
|
596
|
+
return true;
|
597
|
+
}
|
598
|
+
}
|
637
599
|
return false;
|
638
600
|
}
|
639
601
|
|
640
|
-
static int parse_options_cb(VALUE k, VALUE v, VALUE opts)
|
641
|
-
{
|
602
|
+
static int parse_options_cb(VALUE k, VALUE v, VALUE opts) {
|
642
603
|
Options copts = (Options)opts;
|
643
604
|
size_t len;
|
644
605
|
|
@@ -753,8 +714,7 @@ static int parse_options_cb(VALUE k, VALUE v, VALUE opts)
|
|
753
714
|
} else if (rails_sym == v) {
|
754
715
|
copts->mode = RailsMode;
|
755
716
|
} else {
|
756
|
-
rb_raise(rb_eArgError,
|
757
|
-
":mode must be :object, :strict, :compat, :null, :custom, :rails, or :wab.");
|
717
|
+
rb_raise(rb_eArgError, ":mode must be :object, :strict, :compat, :null, :custom, :rails, or :wab.");
|
758
718
|
}
|
759
719
|
} else if (time_format_sym == k) {
|
760
720
|
if (unix_sym == v) {
|
@@ -780,8 +740,7 @@ static int parse_options_cb(VALUE k, VALUE v, VALUE opts)
|
|
780
740
|
} else if (unicode_xss_sym == v) {
|
781
741
|
copts->escape_mode = JXEsc;
|
782
742
|
} else {
|
783
|
-
rb_raise(rb_eArgError,
|
784
|
-
":encoding must be :newline, :json, :xss_safe, :unicode_xss, or :ascii.");
|
743
|
+
rb_raise(rb_eArgError, ":encoding must be :newline, :json, :xss_safe, :unicode_xss, or :ascii.");
|
785
744
|
}
|
786
745
|
} else if (bigdecimal_load_sym == k) {
|
787
746
|
if (Qnil == v) {
|
@@ -892,7 +851,6 @@ static int parse_options_cb(VALUE k, VALUE v, VALUE opts)
|
|
892
851
|
if (Qnil == v) {
|
893
852
|
return ST_CONTINUE;
|
894
853
|
}
|
895
|
-
|
896
854
|
if (null_sym == v) {
|
897
855
|
copts->dump_opts.nan_dump = NullNan;
|
898
856
|
} else if (huge_sym == v) {
|
@@ -910,7 +868,6 @@ static int parse_options_cb(VALUE k, VALUE v, VALUE opts)
|
|
910
868
|
if (Qnil == v) {
|
911
869
|
return ST_CONTINUE;
|
912
870
|
}
|
913
|
-
|
914
871
|
if (Qtrue == v) {
|
915
872
|
copts->dump_opts.omit_nil = true;
|
916
873
|
} else if (Qfalse == v) {
|
@@ -918,7 +875,7 @@ static int parse_options_cb(VALUE k, VALUE v, VALUE opts)
|
|
918
875
|
} else {
|
919
876
|
rb_raise(rb_eArgError, ":omit_nil must be true or false.");
|
920
877
|
}
|
921
|
-
} else if(oj_ascii_only_sym == k) {
|
878
|
+
} else if (oj_ascii_only_sym == k) {
|
922
879
|
// This is here only for backwards compatibility with the original Oj.
|
923
880
|
if (Qtrue == v) {
|
924
881
|
copts->escape_mode = ASCIIEsc;
|
@@ -968,7 +925,6 @@ static int parse_options_cb(VALUE k, VALUE v, VALUE opts)
|
|
968
925
|
if (Qnil == v) {
|
969
926
|
return ST_CONTINUE;
|
970
927
|
}
|
971
|
-
|
972
928
|
if (TYPE(v) == T_STRUCT && rb_obj_class(v) == rb_cRange) {
|
973
929
|
VALUE min = rb_funcall(v, oj_begin_id, 0);
|
974
930
|
VALUE max = rb_funcall(v, oj_end_id, 0);
|
@@ -982,8 +938,12 @@ static int parse_options_cb(VALUE k, VALUE v, VALUE opts)
|
|
982
938
|
} else if (Qfalse != v) {
|
983
939
|
rb_raise(rb_eArgError, ":integer_range must be a range of Fixnum.");
|
984
940
|
}
|
941
|
+
} else if (symbol_keys_sym == k || oj_symbolize_names_sym == k) {
|
942
|
+
if (Qnil == v) {
|
943
|
+
return ST_CONTINUE;
|
944
|
+
}
|
945
|
+
copts->sym_key = (Qtrue == v) ? Yes : No;
|
985
946
|
}
|
986
|
-
|
987
947
|
return ST_CONTINUE;
|
988
948
|
}
|
989
949
|
|
@@ -1014,9 +974,7 @@ static int match_string_cb(VALUE key, VALUE value, VALUE rx) {
|
|
1014
974
|
rb_raise(rb_eArgError, "%s", rc->err);
|
1015
975
|
}
|
1016
976
|
break;
|
1017
|
-
default:
|
1018
|
-
rb_raise(rb_eArgError, "for :match_string, keys must either a String or RegExp.");
|
1019
|
-
break;
|
977
|
+
default: rb_raise(rb_eArgError, "for :match_string, keys must either a String or RegExp."); break;
|
1020
978
|
}
|
1021
979
|
return ST_CONTINUE;
|
1022
980
|
}
|
@@ -1184,9 +1142,7 @@ static VALUE load_file(int argc, VALUE *argv, VALUE self) {
|
|
1184
1142
|
} else if (wab_sym == v) {
|
1185
1143
|
mode = WabMode;
|
1186
1144
|
} else {
|
1187
|
-
rb_raise(
|
1188
|
-
rb_eArgError,
|
1189
|
-
":mode must be :object, :strict, :compat, :null, :custom, :rails, or :wab.");
|
1145
|
+
rb_raise(rb_eArgError, ":mode must be :object, :strict, :compat, :null, :custom, :rails, or :wab.");
|
1190
1146
|
}
|
1191
1147
|
}
|
1192
1148
|
}
|
@@ -1264,16 +1220,15 @@ static VALUE safe_load(VALUE self, VALUE doc) {
|
|
1264
1220
|
*/
|
1265
1221
|
|
1266
1222
|
struct dump_arg {
|
1267
|
-
struct _out
|
1223
|
+
struct _out * out;
|
1268
1224
|
struct _options *copts;
|
1269
|
-
int
|
1270
|
-
VALUE *argv;
|
1225
|
+
int argc;
|
1226
|
+
VALUE * argv;
|
1271
1227
|
};
|
1272
1228
|
|
1273
|
-
static VALUE dump_body(VALUE a)
|
1274
|
-
{
|
1229
|
+
static VALUE dump_body(VALUE a) {
|
1275
1230
|
volatile struct dump_arg *arg = (void *)a;
|
1276
|
-
VALUE
|
1231
|
+
VALUE rstr;
|
1277
1232
|
|
1278
1233
|
oj_dump_obj_to_json_using_params(*arg->argv, arg->copts, arg->out, arg->argc - 1, arg->argv + 1);
|
1279
1234
|
if (0 == arg->out->buf) {
|
@@ -1285,8 +1240,7 @@ static VALUE dump_body(VALUE a)
|
|
1285
1240
|
return rstr;
|
1286
1241
|
}
|
1287
1242
|
|
1288
|
-
static VALUE dump_ensure(VALUE a)
|
1289
|
-
{
|
1243
|
+
static VALUE dump_ensure(VALUE a) {
|
1290
1244
|
volatile struct dump_arg *arg = (void *)a;
|
1291
1245
|
|
1292
1246
|
if (arg->out->allocated) {
|
@@ -1320,10 +1274,10 @@ static VALUE dump(int argc, VALUE *argv, VALUE self) {
|
|
1320
1274
|
if (CompatMode == copts.mode && copts.escape_mode != ASCIIEsc) {
|
1321
1275
|
copts.escape_mode = JSONEsc;
|
1322
1276
|
}
|
1323
|
-
arg.out
|
1277
|
+
arg.out = &out;
|
1324
1278
|
arg.copts = &copts;
|
1325
|
-
arg.argc
|
1326
|
-
arg.argv
|
1279
|
+
arg.argc = argc;
|
1280
|
+
arg.argv = argv;
|
1327
1281
|
|
1328
1282
|
arg.out->buf = buf;
|
1329
1283
|
arg.out->end = buf + sizeof(buf) - 10;
|
@@ -2015,6 +1969,8 @@ void Init_oj() {
|
|
2015
1969
|
rb_gc_register_address(&strict_sym);
|
2016
1970
|
symbol_keys_sym = ID2SYM(rb_intern("symbol_keys"));
|
2017
1971
|
rb_gc_register_address(&symbol_keys_sym);
|
1972
|
+
oj_symbolize_names_sym = ID2SYM(rb_intern("symbolize_names"));
|
1973
|
+
rb_gc_register_address(&oj_symbolize_names_sym);
|
2018
1974
|
time_format_sym = ID2SYM(rb_intern("time_format"));
|
2019
1975
|
rb_gc_register_address(&time_format_sym);
|
2020
1976
|
unicode_xss_sym = ID2SYM(rb_intern("unicode_xss"));
|
data/ext/oj/oj.h
CHANGED
data/lib/oj/version.rb
CHANGED
data/test/foo.rb
CHANGED
@@ -4,11 +4,17 @@ $: << '.'
|
|
4
4
|
$: << File.join(File.dirname(__FILE__), "../lib")
|
5
5
|
$: << File.join(File.dirname(__FILE__), "../ext")
|
6
6
|
|
7
|
+
# require 'json'
|
7
8
|
require 'oj'
|
9
|
+
Oj.mimic_JSON
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
pp
|
14
|
-
|
11
|
+
source = %( {"a": 1, "b": 2} )
|
12
|
+
puts "JSON.load, no symbolize => OK"
|
13
|
+
pp JSON.load( source )
|
14
|
+
puts "JSON.load, do symbolize => KO: keys are not symbols"
|
15
|
+
#pp JSON.load( source, nil, symbolize_names: true, create_additions: false )
|
16
|
+
pp JSON.load( source, nil, symbolize_names: true, create_additions: false )
|
17
|
+
puts "JSON.parse, no symbolize => OK"
|
18
|
+
pp JSON.parse( source )
|
19
|
+
puts "JSON.parse, do symbolize => OK"
|
20
|
+
pp JSON.parse( source, symbolize_names: true )
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.13.
|
4
|
+
version: 3.13.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|