oj 3.16.3 → 3.17.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +99 -0
  3. data/README.md +0 -16
  4. data/ext/oj/compat.c +3 -3
  5. data/ext/oj/custom.c +17 -11
  6. data/ext/oj/dump.c +619 -88
  7. data/ext/oj/dump.h +9 -2
  8. data/ext/oj/dump_compat.c +16 -9
  9. data/ext/oj/dump_leaf.c +1 -1
  10. data/ext/oj/dump_object.c +52 -27
  11. data/ext/oj/dump_strict.c +20 -14
  12. data/ext/oj/extconf.rb +11 -9
  13. data/ext/oj/fast.c +90 -65
  14. data/ext/oj/intern.c +1 -1
  15. data/ext/oj/mimic_json.c +14 -8
  16. data/ext/oj/object.c +18 -12
  17. data/ext/oj/oj.c +426 -11
  18. data/ext/oj/oj.h +60 -52
  19. data/ext/oj/parse.c +252 -48
  20. data/ext/oj/parse.h +0 -1
  21. data/ext/oj/parser.c +179 -47
  22. data/ext/oj/parser.h +4 -2
  23. data/ext/oj/rails.c +57 -36
  24. data/ext/oj/reader.c +17 -5
  25. data/ext/oj/rxclass.c +17 -1
  26. data/ext/oj/rxclass.h +2 -1
  27. data/ext/oj/safe.c +230 -0
  28. data/ext/oj/safe.h +79 -0
  29. data/ext/oj/saj.c +55 -20
  30. data/ext/oj/scp.c +3 -6
  31. data/ext/oj/simd.h +219 -0
  32. data/ext/oj/sparse.c +15 -3
  33. data/ext/oj/stream_writer.c +19 -14
  34. data/ext/oj/strict.c +2 -4
  35. data/ext/oj/string_writer.c +26 -14
  36. data/ext/oj/usual.c +37 -35
  37. data/ext/oj/wab.c +5 -4
  38. data/lib/oj/mimic.rb +1 -5
  39. data/lib/oj/schandler.rb +5 -4
  40. data/lib/oj/version.rb +1 -1
  41. data/pages/Encoding.md +1 -1
  42. metadata +22 -100
  43. data/test/_test_active.rb +0 -75
  44. data/test/_test_active_mimic.rb +0 -95
  45. data/test/_test_mimic_rails.rb +0 -123
  46. data/test/activerecord/result_test.rb +0 -31
  47. data/test/activesupport6/abstract_unit.rb +0 -44
  48. data/test/activesupport6/decoding_test.rb +0 -133
  49. data/test/activesupport6/encoding_test.rb +0 -507
  50. data/test/activesupport6/encoding_test_cases.rb +0 -98
  51. data/test/activesupport6/test_common.rb +0 -17
  52. data/test/activesupport6/test_helper.rb +0 -163
  53. data/test/activesupport6/time_zone_test_helpers.rb +0 -39
  54. data/test/activesupport7/abstract_unit.rb +0 -49
  55. data/test/activesupport7/decoding_test.rb +0 -125
  56. data/test/activesupport7/encoding_test.rb +0 -486
  57. data/test/activesupport7/encoding_test_cases.rb +0 -104
  58. data/test/activesupport7/time_zone_test_helpers.rb +0 -47
  59. data/test/files.rb +0 -29
  60. data/test/foo.rb +0 -14
  61. data/test/helper.rb +0 -39
  62. data/test/isolated/shared.rb +0 -309
  63. data/test/isolated/test_mimic_after.rb +0 -13
  64. data/test/isolated/test_mimic_alone.rb +0 -12
  65. data/test/isolated/test_mimic_as_json.rb +0 -45
  66. data/test/isolated/test_mimic_before.rb +0 -13
  67. data/test/isolated/test_mimic_define.rb +0 -28
  68. data/test/isolated/test_mimic_rails_after.rb +0 -22
  69. data/test/isolated/test_mimic_rails_before.rb +0 -21
  70. data/test/isolated/test_mimic_redefine.rb +0 -15
  71. data/test/json_gem/json_addition_test.rb +0 -216
  72. data/test/json_gem/json_common_interface_test.rb +0 -155
  73. data/test/json_gem/json_encoding_test.rb +0 -107
  74. data/test/json_gem/json_ext_parser_test.rb +0 -21
  75. data/test/json_gem/json_fixtures_test.rb +0 -36
  76. data/test/json_gem/json_generator_test.rb +0 -413
  77. data/test/json_gem/json_generic_object_test.rb +0 -90
  78. data/test/json_gem/json_parser_test.rb +0 -477
  79. data/test/json_gem/json_string_matching_test.rb +0 -42
  80. data/test/json_gem/test_helper.rb +0 -30
  81. data/test/mem.rb +0 -34
  82. data/test/perf.rb +0 -102
  83. data/test/perf_compat.rb +0 -128
  84. data/test/perf_dump.rb +0 -50
  85. data/test/perf_fast.rb +0 -162
  86. data/test/perf_file.rb +0 -62
  87. data/test/perf_object.rb +0 -134
  88. data/test/perf_once.rb +0 -59
  89. data/test/perf_parser.rb +0 -183
  90. data/test/perf_saj.rb +0 -101
  91. data/test/perf_scp.rb +0 -140
  92. data/test/perf_simple.rb +0 -289
  93. data/test/perf_strict.rb +0 -137
  94. data/test/perf_wab.rb +0 -129
  95. data/test/prec.rb +0 -23
  96. data/test/sample/change.rb +0 -13
  97. data/test/sample/dir.rb +0 -18
  98. data/test/sample/doc.rb +0 -35
  99. data/test/sample/file.rb +0 -47
  100. data/test/sample/group.rb +0 -15
  101. data/test/sample/hasprops.rb +0 -15
  102. data/test/sample/layer.rb +0 -11
  103. data/test/sample/line.rb +0 -20
  104. data/test/sample/oval.rb +0 -10
  105. data/test/sample/rect.rb +0 -9
  106. data/test/sample/shape.rb +0 -34
  107. data/test/sample/text.rb +0 -19
  108. data/test/sample.rb +0 -54
  109. data/test/sample_json.rb +0 -37
  110. data/test/test_compat.rb +0 -567
  111. data/test/test_custom.rb +0 -555
  112. data/test/test_debian.rb +0 -50
  113. data/test/test_fast.rb +0 -526
  114. data/test/test_file.rb +0 -250
  115. data/test/test_gc.rb +0 -60
  116. data/test/test_generate.rb +0 -21
  117. data/test/test_hash.rb +0 -39
  118. data/test/test_integer_range.rb +0 -72
  119. data/test/test_null.rb +0 -376
  120. data/test/test_object.rb +0 -1030
  121. data/test/test_parser.rb +0 -11
  122. data/test/test_parser_debug.rb +0 -27
  123. data/test/test_parser_saj.rb +0 -337
  124. data/test/test_parser_usual.rb +0 -227
  125. data/test/test_rails.rb +0 -35
  126. data/test/test_saj.rb +0 -188
  127. data/test/test_scp.rb +0 -431
  128. data/test/test_strict.rb +0 -441
  129. data/test/test_various.rb +0 -801
  130. data/test/test_wab.rb +0 -311
  131. data/test/test_writer.rb +0 -380
  132. data/test/tests.rb +0 -33
  133. data/test/tests_mimic.rb +0 -23
  134. data/test/tests_mimic_addition.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a6b15904386e7010fa071ecc27b8f3a6d5023c8162ea7042fc39e29c373a20a
4
- data.tar.gz: b862e59cff0ba3a15eadec34fe807d5893c9c1d1e9fcce01ced66ab28e642181
3
+ metadata.gz: 8bbb833f16ca15e4591772c707b059e1db37eee8aaf02240cd2f628bf1876f4c
4
+ data.tar.gz: 8020f6e49607b38fb120a5a6ea4eea9e5ba3e73f35b3556b7defb0202e93e015
5
5
  SHA512:
6
- metadata.gz: f186fb40ebcc3792b4949f81ce3b2efb22bee9dce9b44785eeca37cc27e25b79e8afa4fc5872232001d28a3d0b279fc222d5f7d2f8aaa091fe3a135246139b64
7
- data.tar.gz: 9c1536bfc15eb3fe02e92d803417ef1ccce5084036aaf8df5ae2b61995a429ab8ae00be5e9b7c79e11839d781c67523ed5bc534df36a40b59dcc61db6551158f
6
+ metadata.gz: df072519e6d25cc38a04328022741db7bfe3d39a1545337aa6828982eaf233673ee2e04bb697ffb037aa25e0521258881ea96204d8a5d46b0a93b80dc002e94e
7
+ data.tar.gz: d0683f49f90c751beeb45b2d1ffb39238fd7c0c42e8c2970ed76eeb8ab2f382221c3ef7cdbc7d619ea29c50b7b3bf29559a8ae1e3ec34aa9b56e13a8fb02eac5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,103 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 3.17.4 - 2026-07-14
4
+
5
+ - Fixed issue in fast.c where rescuing from a panic did not reset the where counter.
6
+
7
+ - Multiple fixes thanks to @Watson1978.
8
+
9
+ ## 3.17.3 - 2026-06-04
10
+
11
+ - Fixed issue in intern.c and fast.c.
12
+
13
+ ## 3.17.2 - 2026-05-27
14
+
15
+ - Fixed multiple issues related to extreme sizes.
16
+
17
+ ## 3.17.1 - 2026-05-15
18
+
19
+ - Fixed "quoted string not terminated" error.
20
+
21
+ ## 3.17.0 - 2026-04-19
22
+
23
+ - A "safe" parser has been added as a variation of the Oj:Parser thanks to @meinac.
24
+
25
+ ## 3.16.17 - 2026-04-12
26
+
27
+ - Rails optimize for Hash and Array now overrides `as_json` for those
28
+ classes. Note that when either is optimized with `Oj.optimize_rails`
29
+ the `Array.as_json` and `Hash.as_json` will not be called.
30
+
31
+ - Add support for the rails encoder `:only` and `:except` options.
32
+
33
+ - Handle unterminated strings in usual parser (#1002)
34
+
35
+ - Fix read() not handling partial reads for large files (#1004)
36
+
37
+ - Raise error for incomplete primitive literals (#1005)
38
+
39
+ ## 3.16.16 - 2026-03-13
40
+
41
+ - Not closed arrays and objects are reported corrected in the usual parser.
42
+
43
+ ## 3.16.15 - 2026-02-05
44
+
45
+ - Fixed by putting the ostruct dependency back until a better way is found to conditionally include it.
46
+
47
+ ## 3.16.14 - 2026-02-04
48
+
49
+ - Fixed SSE issue #989.
50
+
51
+ - Removed ostruct dependency.
52
+
53
+ - Removed generic object JSON gem tests.
54
+
55
+ ## 3.16.13 - 2025-12-05
56
+
57
+ - Fixed rails encoding for Hash and Array subclasses.
58
+
59
+ ## 3.16.12 - 2025-10-29
60
+
61
+ - Fixed dump realloc bug that occurred when using the compat mode dump options.
62
+
63
+ ## 3.16.11 - 2025-05-29
64
+
65
+ - Fixed range encoding with the :circular option
66
+
67
+ ## 3.16.10 - 2025-02-24
68
+
69
+ - Changed oj_parser_type to be non-static.
70
+
71
+ - Changed ARM versions to used Neon instructions thanks to @samyron.
72
+
73
+ ## 3.16.9 - 2024-12-28
74
+
75
+ - Fixed `Oj::Parser` create_id size issue #931.
76
+
77
+ - Changed parser to be more optimized (PR from @Watson1978)
78
+
79
+ ## 3.16.8 - 2024-12-14
80
+
81
+ - Fixed StreamWriter to write to non-file IO thanks to @jscheid.
82
+
83
+ ## 3.16.7 - 2024-11-01
84
+
85
+ - Changed string_writer_as_json to allow multiple arguments.
86
+
87
+ - Fixed Global variable registration added to mimic_json and rails code thanks to @byroot.
88
+
89
+ ## 3.16.6 - 2024-09-09
90
+
91
+ - Fixed issue with Rails 7.2 that changed the order of calls to to_json and as_json.
92
+
93
+ ## 3.16.5 - 2024-08-07
94
+
95
+ - Fixed Oj::Parser so that block procedures work correctly.
96
+
97
+ ## 3.16.4 - 2024-06-08
98
+
99
+ - Fixed Oj::Parse EOF issue on larger stream input.
100
+
3
101
  ## 3.16.3 - 2023-12-11
4
102
 
5
103
  - Fixed the gemspec to allow earlier versions of the bigdecimal gem.
@@ -36,6 +134,7 @@
36
134
  ## 3.14.3 - 2023-04-07
37
135
 
38
136
  - Fixed compat parse with optimized Hash when parsing a JSON::GenericObject.
137
+ - Deprecated Ruby <= 2.6.10
39
138
 
40
139
  ## 3.14.2 - 2023-02-10
41
140
 
data/README.md CHANGED
@@ -46,11 +46,6 @@ gem 'oj'
46
46
 
47
47
  See the Quickstart sections of the [Rails](pages/Rails.md) and [json](pages/JsonGem.md) docs.
48
48
 
49
- ## multi_json
50
-
51
- Code which uses [multi_json](https://github.com/intridea/multi_json)
52
- will automatically prefer Oj if it is installed.
53
-
54
49
  ## Support
55
50
 
56
51
  [Get supported Oj with a Tidelift Subscription.](https://tidelift.com/subscription/pkg/rubygems-oj?utm_source=rubygems-oj&utm_medium=referral&utm_campaign=readme) Security updates are [supported](https://tidelift.com/security).
@@ -83,17 +78,6 @@ See [{file:CHANGELOG.md}](CHANGELOG.md) and [{file:RELEASE_NOTES.md}](RELEASE_NO
83
78
 
84
79
  - *RubyGems* *repo*: https://rubygems.org/gems/oj
85
80
 
86
- Follow [@peterohler on Twitter](http://twitter.com/peterohler) for announcements and news about the Oj gem.
87
-
88
- #### Performance Comparisons
89
-
90
- - [Oj Strict Mode Performance](http://www.ohler.com/dev/oj_misc/performance_strict.html) compares Oj strict mode parser performance to other JSON parsers.
91
-
92
- - [Oj Compat Mode Performance](http://www.ohler.com/dev/oj_misc/performance_compat.html) compares Oj compat mode parser performance to other JSON parsers.
93
-
94
- - [Oj Object Mode Performance](http://www.ohler.com/dev/oj_misc/performance_object.html) compares Oj object mode parser performance to other marshallers.
95
-
96
- - [Oj Callback Performance](http://www.ohler.com/dev/oj_misc/performance_callback.html) compares Oj callback parser performance to other JSON parsers.
97
81
 
98
82
  #### Links of Interest
99
83
 
data/ext/oj/compat.c CHANGED
@@ -27,7 +27,7 @@ static void hash_set_cstr(ParseInfo pi, Val kval, const char *str, size_t len, c
27
27
  volatile VALUE rkey = oj_calc_hash_key(pi, kval);
28
28
 
29
29
  if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
30
- VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
30
+ VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, len);
31
31
 
32
32
  if (Qnil != clas) {
33
33
  rstr = rb_funcall(clas, oj_json_create_id, 1, rstr);
@@ -84,7 +84,7 @@ static void add_cstr(ParseInfo pi, const char *str, size_t len, const char *orig
84
84
  volatile VALUE rstr = oj_cstr_to_value(str, len, (size_t)pi->options.cache_str);
85
85
 
86
86
  if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
87
- VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
87
+ VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, len);
88
88
 
89
89
  if (Qnil != clas) {
90
90
  pi->stack.head->val = rb_funcall(clas, oj_json_create_id, 1, rstr);
@@ -155,7 +155,7 @@ static void array_append_cstr(ParseInfo pi, const char *str, size_t len, const c
155
155
  volatile VALUE rstr = oj_cstr_to_value(str, len, (size_t)pi->options.cache_str);
156
156
 
157
157
  if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
158
- VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
158
+ VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, len);
159
159
 
160
160
  if (Qnil != clas) {
161
161
  rb_ary_push(stack_peek(&pi->stack)->val, rb_funcall(clas, oj_json_create_id, 1, rstr));
data/ext/oj/custom.c CHANGED
@@ -40,7 +40,7 @@ static void dump_obj_as_str(VALUE obj, int depth, Out out) {
40
40
  static void bigdecimal_dump(VALUE obj, int depth, Out out) {
41
41
  volatile VALUE rstr = oj_safe_string_convert(obj);
42
42
  const char *str = RSTRING_PTR(rstr);
43
- int len = (int)RSTRING_LEN(rstr);
43
+ size_t len = RSTRING_LEN(rstr);
44
44
 
45
45
  if (0 == strcasecmp("Infinity", str)) {
46
46
  str = oj_nan_str(obj, out->opts->dump_opts.nan_dump, out->opts->mode, true, &len);
@@ -123,7 +123,7 @@ static void date_dump(VALUE obj, int depth, Out out) {
123
123
  case RubyTime:
124
124
  case XmlTime:
125
125
  v = rb_funcall(obj, rb_intern("iso8601"), 0);
126
- oj_dump_cstr(RSTRING_PTR(v), (int)RSTRING_LEN(v), 0, 0, out);
126
+ oj_dump_cstr(RSTRING_PTR(v), RSTRING_LEN(v), 0, 0, out);
127
127
  break;
128
128
  case UnixZTime:
129
129
  v = rb_funcall(obj, rb_intern("to_time"), 0);
@@ -287,6 +287,11 @@ static int hash_cb(VALUE key, VALUE value, VALUE ov) {
287
287
  if (out->omit_nil && Qnil == value) {
288
288
  return ST_CONTINUE;
289
289
  }
290
+ if (NULL != out->opts->dump_opts.only || NULL != out->opts->dump_opts.except) {
291
+ if (oj_key_skip(key, out->opts->dump_opts.only, out->opts->dump_opts.except)) {
292
+ return ST_CONTINUE;
293
+ }
294
+ }
290
295
  if (!out->opts->dump_opts.use) {
291
296
  assure_size(out, depth * out->indent + 1);
292
297
  fill_indent(out, depth);
@@ -405,7 +410,7 @@ static void dump_odd(VALUE obj, Odd odd, VALUE clas, int depth, Out out) {
405
410
  rb_raise(rb_eEncodingError, "Invalid type for raw JSON.\n");
406
411
  } else {
407
412
  const char *s = RSTRING_PTR(v);
408
- int len = (int)RSTRING_LEN(v);
413
+ size_t len = RSTRING_LEN(v);
409
414
  const char *name = rb_id2name(*odd->attrs);
410
415
  size_t nlen = strlen(name);
411
416
 
@@ -478,7 +483,7 @@ static VALUE dump_common(VALUE obj, int depth, Out out) {
478
483
  } else if (Yes == out->opts->to_json && rb_respond_to(obj, oj_to_json_id)) {
479
484
  volatile VALUE rs;
480
485
  const char *s;
481
- int len;
486
+ size_t len;
482
487
 
483
488
  TRACE(out->opts->trace, "to_json", obj, depth + 1, TraceRubyIn);
484
489
  if (0 == rb_obj_method_arity(obj, oj_to_json_id)) {
@@ -488,7 +493,7 @@ static VALUE dump_common(VALUE obj, int depth, Out out) {
488
493
  }
489
494
  TRACE(out->opts->trace, "to_json", obj, depth + 1, TraceRubyOut);
490
495
  s = RSTRING_PTR(rs);
491
- len = (int)RSTRING_LEN(rs);
496
+ len = RSTRING_LEN(rs);
492
497
 
493
498
  assure_size(out, len + 1);
494
499
  APPEND_CHARS(out->cur, s, len);
@@ -509,7 +514,7 @@ static VALUE dump_common(VALUE obj, int depth, Out out) {
509
514
  if (aj == obj) {
510
515
  volatile VALUE rstr = oj_safe_string_convert(obj);
511
516
 
512
- oj_dump_cstr(RSTRING_PTR(rstr), (int)RSTRING_LEN(rstr), false, false, out);
517
+ oj_dump_cstr(RSTRING_PTR(rstr), RSTRING_LEN(rstr), false, false, out);
513
518
  } else {
514
519
  oj_dump_custom_val(aj, depth, out, true);
515
520
  }
@@ -676,7 +681,8 @@ static void dump_obj(VALUE obj, int depth, Out out, bool as_ok) {
676
681
 
677
682
  static void dump_array(VALUE a, int depth, Out out, bool as_ok) {
678
683
  size_t size;
679
- int i, cnt;
684
+ size_t i;
685
+ size_t cnt;
680
686
  int d2 = depth + 1;
681
687
  long id = oj_check_circular(a, out);
682
688
 
@@ -684,7 +690,7 @@ static void dump_array(VALUE a, int depth, Out out, bool as_ok) {
684
690
  oj_dump_nil(Qnil, depth, out, false);
685
691
  return;
686
692
  }
687
- cnt = (int)RARRAY_LEN(a);
693
+ cnt = RARRAY_LEN(a);
688
694
  *out->cur++ = '[';
689
695
  assure_size(out, 2);
690
696
  if (0 == cnt) {
@@ -795,7 +801,7 @@ static void dump_struct(VALUE obj, int depth, Out out, bool as_ok) {
795
801
  volatile VALUE s = rb_sym2str(RARRAY_AREF(ma, i));
796
802
 
797
803
  name = RSTRING_PTR(s);
798
- len = (int)RSTRING_LEN(s);
804
+ len = RSTRING_LEN(s);
799
805
  } else {
800
806
  len = snprintf(num_id, sizeof(num_id), "%d", i);
801
807
  name = num_id;
@@ -909,7 +915,7 @@ static void hash_set_cstr(ParseInfo pi, Val kval, const char *str, size_t len, c
909
915
  volatile VALUE rkey = oj_calc_hash_key(pi, kval);
910
916
 
911
917
  if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
912
- VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
918
+ VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, len);
913
919
 
914
920
  if (Qnil != clas) {
915
921
  rstr = rb_funcall(clas, oj_json_create_id, 1, rstr);
@@ -1014,7 +1020,7 @@ static void array_append_cstr(ParseInfo pi, const char *str, size_t len, const c
1014
1020
  volatile VALUE rstr = rb_utf8_str_new(str, len);
1015
1021
 
1016
1022
  if (Yes == pi->options.create_ok && NULL != pi->options.str_rx.head) {
1017
- VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, (int)len);
1023
+ VALUE clas = oj_rxclass_match(&pi->options.str_rx, str, len);
1018
1024
 
1019
1025
  if (Qnil != clas) {
1020
1026
  rb_ary_push(stack_peek(&pi->stack)->val, rb_funcall(clas, oj_json_create_id, 1, rstr));