json 2.4.0 → 2.6.0

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +27 -5
  3. data/README.md +3 -3
  4. data/VERSION +1 -1
  5. data/ext/json/ext/generator/generator.c +13 -17
  6. data/ext/json/ext/parser/extconf.rb +1 -0
  7. data/ext/json/ext/parser/parser.c +2971 -1797
  8. data/ext/json/ext/parser/parser.h +5 -1
  9. data/ext/json/ext/parser/parser.rl +106 -53
  10. data/json.gemspec +3 -76
  11. data/lib/json/common.rb +34 -13
  12. data/lib/json/pure/parser.rb +1 -1
  13. data/lib/json/version.rb +1 -1
  14. data/lib/json.rb +1 -1
  15. metadata +7 -110
  16. data/.gitignore +0 -18
  17. data/.travis.yml +0 -23
  18. data/Gemfile +0 -14
  19. data/README-json-jruby.md +0 -33
  20. data/Rakefile +0 -334
  21. data/diagrams/.keep +0 -0
  22. data/install.rb +0 -23
  23. data/java/src/json/ext/ByteListTranscoder.java +0 -166
  24. data/java/src/json/ext/Generator.java +0 -447
  25. data/java/src/json/ext/GeneratorMethods.java +0 -231
  26. data/java/src/json/ext/GeneratorService.java +0 -42
  27. data/java/src/json/ext/GeneratorState.java +0 -520
  28. data/java/src/json/ext/OptionsReader.java +0 -113
  29. data/java/src/json/ext/Parser.java +0 -2374
  30. data/java/src/json/ext/Parser.rl +0 -905
  31. data/java/src/json/ext/ParserService.java +0 -34
  32. data/java/src/json/ext/RuntimeInfo.java +0 -116
  33. data/java/src/json/ext/StringDecoder.java +0 -166
  34. data/java/src/json/ext/StringEncoder.java +0 -117
  35. data/java/src/json/ext/Utils.java +0 -88
  36. data/json-java.gemspec +0 -38
  37. data/json_pure.gemspec +0 -33
  38. data/lib/json/ext/.keep +0 -0
  39. data/references/rfc7159.txt +0 -899
  40. data/tests/fixtures/fail10.json +0 -1
  41. data/tests/fixtures/fail11.json +0 -1
  42. data/tests/fixtures/fail12.json +0 -1
  43. data/tests/fixtures/fail13.json +0 -1
  44. data/tests/fixtures/fail14.json +0 -1
  45. data/tests/fixtures/fail18.json +0 -1
  46. data/tests/fixtures/fail19.json +0 -1
  47. data/tests/fixtures/fail2.json +0 -1
  48. data/tests/fixtures/fail20.json +0 -1
  49. data/tests/fixtures/fail21.json +0 -1
  50. data/tests/fixtures/fail22.json +0 -1
  51. data/tests/fixtures/fail23.json +0 -1
  52. data/tests/fixtures/fail24.json +0 -1
  53. data/tests/fixtures/fail25.json +0 -1
  54. data/tests/fixtures/fail27.json +0 -2
  55. data/tests/fixtures/fail28.json +0 -2
  56. data/tests/fixtures/fail3.json +0 -1
  57. data/tests/fixtures/fail4.json +0 -1
  58. data/tests/fixtures/fail5.json +0 -1
  59. data/tests/fixtures/fail6.json +0 -1
  60. data/tests/fixtures/fail7.json +0 -1
  61. data/tests/fixtures/fail8.json +0 -1
  62. data/tests/fixtures/fail9.json +0 -1
  63. data/tests/fixtures/obsolete_fail1.json +0 -1
  64. data/tests/fixtures/pass1.json +0 -56
  65. data/tests/fixtures/pass15.json +0 -1
  66. data/tests/fixtures/pass16.json +0 -1
  67. data/tests/fixtures/pass17.json +0 -1
  68. data/tests/fixtures/pass2.json +0 -1
  69. data/tests/fixtures/pass26.json +0 -1
  70. data/tests/fixtures/pass3.json +0 -6
  71. data/tests/json_addition_test.rb +0 -199
  72. data/tests/json_common_interface_test.rb +0 -169
  73. data/tests/json_encoding_test.rb +0 -107
  74. data/tests/json_ext_parser_test.rb +0 -15
  75. data/tests/json_fixtures_test.rb +0 -40
  76. data/tests/json_generator_test.rb +0 -432
  77. data/tests/json_generic_object_test.rb +0 -82
  78. data/tests/json_parser_test.rb +0 -497
  79. data/tests/json_string_matching_test.rb +0 -38
  80. data/tests/test_helper.rb +0 -17
  81. data/tools/diff.sh +0 -18
  82. data/tools/fuzz.rb +0 -131
  83. data/tools/server.rb +0 -62
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b5241427373f8f03f7faa96afdec132dcb7601f2e9cce4903ce0879c208bc3f
4
- data.tar.gz: 7e3e820aae7a8036affec28ce44f4aadeebfd74b4bea85ad2d597eb42e82b745
3
+ metadata.gz: dcc1346522e82980a0a5891f93738a33d0d367b0013e22440a85282b6d56721e
4
+ data.tar.gz: a7d4a06c398e9a550664e29096f85eaab0f7007bac945e69d3b869b24df2017b
5
5
  SHA512:
6
- metadata.gz: e0f403e2c458aa86f820671726a92f4798703240099417a22e5d489d140f53d48559560d6603547f2a0f07aa0595fb383c4b1b2c53e1df1b34e16df2ca4ea480
7
- data.tar.gz: 5e0f19fe6c8c086adbe499b85bb49c1b5f14697cb63ed8d7fd96d82e8504806eb0b016f8e2a556ec7eab5443beddc8109d2ef5921bd3ac54eedf45056218924b
6
+ metadata.gz: 91235d83102ee7de2a1263a6b4d351fa61a3fa9440a31dc00cd391995721e333e609ab569f93ec9b2ad9e6b68a721d96a18af8e515d77d11c81d7626b82ab0f3
7
+ data.tar.gz: f2dcfe70be72b2df3567ee35bc3f4ecbf170ed6022362bc31cab151609ec3e3a0ef7aa339e81c0816987b25c7132fa222e1a51bc19af8cf4bf8143d66d5ed157
data/CHANGES.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changes
2
2
 
3
+ ## 2020-12-22 (2.5.1)
4
+
5
+ * Restore the compatibility for constants of JSON class.
6
+
7
+ ## 2020-12-22 (2.5.0)
8
+
9
+ * Ready to Ractor-safe at Ruby 3.0.
10
+
11
+ ## 2020-12-17 (2.4.1)
12
+
13
+ * Restore version.rb with 2.4.1
14
+
15
+ ## 2020-12-15 (2.4.0)
16
+
17
+ * Implement a freeze: parser option #447
18
+ * Fix an issue with generate_pretty and empty objects in the Ruby and Java implementations #449
19
+ * Fix JSON.load_file doc #448
20
+ * Fix pure parser with unclosed arrays / objects #425
21
+ * bundle the LICENSE file in the gem #444
22
+ * Add an option to escape forward slash character #405
23
+ * RDoc for JSON #439 #446 #442 #434 #433 #430
24
+
3
25
  ## 2020-06-30 (2.3.1)
4
26
 
5
27
  * Spelling and grammar fixes for comments. Pull request #191 by Josh
@@ -61,7 +83,7 @@
61
83
 
62
84
  ## 2015-09-11 (2.0.0)
63
85
  * Now complies to newest JSON RFC 7159.
64
- * Implements compatibiliy to ruby 2.4 integer unification.
86
+ * Implements compatibility to ruby 2.4 integer unification.
65
87
  * Drops support for old rubies whose life has ended, that is rubies < 2.0.
66
88
  Also see https://www.ruby-lang.org/en/news/2014/07/01/eol-for-1-8-7-and-1-9-2/
67
89
  * There were still some mentions of dual GPL licensing in the source, but JSON
@@ -102,9 +124,9 @@
102
124
  ## 2013-02-04 (1.7.7)
103
125
  * Security fix for JSON create_additions default value and
104
126
  `JSON::GenericObject`. It should not be possible to create additions unless
105
- explicitely requested by setting the create_additions argument to true or
127
+ explicitly requested by setting the create_additions argument to true or
106
128
  using the JSON.load/dump interface. If `JSON::GenericObject` is supposed to
107
- be automatically deserialised, this has to be explicitely enabled by
129
+ be automatically deserialised, this has to be explicitly enabled by
108
130
  setting
109
131
  JSON::GenericObject.json_creatable = true
110
132
  as well.
@@ -250,7 +272,7 @@
250
272
  ## 2010-04-23 (1.4.0)
251
273
  * Major speed improvements and building with simplified
252
274
  directory/file-structure.
253
- * Extension should at least be comapatible with MRI, YARV and Rubinius.
275
+ * Extension should at least be compatible with MRI, YARV and Rubinius.
254
276
 
255
277
  ## 2010-04-07 (1.2.4)
256
278
  * Triger const_missing callback to make Rails' dynamic class loading work.
@@ -268,7 +290,7 @@
268
290
  strings in object names/keys.
269
291
 
270
292
  ## 2009-10-01 (1.2.0)
271
- * `fast_generate` now raises an exeception for nan and infinite floats.
293
+ * `fast_generate` now raises an exception for nan and infinite floats.
272
294
  * On Ruby 1.8 json supports parsing of UTF-8, UTF-16BE, UTF-16LE, UTF-32BE,
273
295
  and UTF-32LE JSON documents now. Under Ruby 1.9 the M17n conversion
274
296
  functions are used to convert from all supported encodings. ASCII-8BIT
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # JSON implementation for Ruby
2
2
 
3
- [![Travis Widget](http://travis-ci.org/flori/json.svg?branch=master)](https://travis-ci.org/flori/json)
3
+ [![CI](https://github.com/flori/json/actions/workflows/ci.yml/badge.svg)](https://github.com/flori/json/actions/workflows/ci.yml)
4
4
 
5
5
  ## Description
6
6
 
@@ -267,7 +267,7 @@ the `pp` library's `pp` methods.
267
267
 
268
268
  The script `tools/server.rb` contains a small example if you want to test, how
269
269
  receiving a JSON object from a webrick server in your browser with the
270
- javasript prototype library http://www.prototypejs.org works.
270
+ JavaScript prototype library http://www.prototypejs.org works.
271
271
 
272
272
  ## Speed Comparisons
273
273
 
@@ -294,7 +294,7 @@ extension:
294
294
  ```
295
295
 
296
296
  In the table above 1 is `JSON::Ext::Parser`, 2 is `YAML.load` with YAML
297
- compatbile JSON document, 3 is is `JSON::Pure::Parser`, and 4 is
297
+ compatible JSON document, 3 is is `JSON::Pure::Parser`, and 4 is
298
298
  `ActiveSupport::JSON.decode`. The ActiveSupport JSON-decoder converts the
299
299
  input first to YAML and then uses the YAML-parser, the conversion seems to
300
300
  slow it down so much that it is only as fast as the `JSON::Pure::Parser`!
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.4.0
1
+ 2.6.0
@@ -1,11 +1,6 @@
1
1
  #include "../fbuffer/fbuffer.h"
2
2
  #include "generator.h"
3
3
 
4
- #ifdef HAVE_RUBY_ENCODING_H
5
- static VALUE CEncoding_UTF_8;
6
- static ID i_encoding, i_encode;
7
- #endif
8
-
9
4
  static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
10
5
  mHash, mArray,
11
6
  #ifdef RUBY_INTEGER_UNIFICATION
@@ -15,8 +10,7 @@ static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
15
10
  #endif
16
11
  mFloat, mString, mString_Extend,
17
12
  mTrueClass, mFalseClass, mNilClass, eGeneratorError,
18
- eNestingError,
19
- i_SAFE_STATE_PROTOTYPE;
13
+ eNestingError;
20
14
 
21
15
  static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before,
22
16
  i_object_nl, i_array_nl, i_max_nesting, i_allow_nan, i_ascii_only,
@@ -620,13 +614,18 @@ static size_t State_memsize(const void *ptr)
620
614
  return size;
621
615
  }
622
616
 
617
+ #ifndef HAVE_RB_EXT_RACTOR_SAFE
618
+ # undef RUBY_TYPED_FROZEN_SHAREABLE
619
+ # define RUBY_TYPED_FROZEN_SHAREABLE 0
620
+ #endif
621
+
623
622
  #ifdef NEW_TYPEDDATA_WRAPPER
624
623
  static const rb_data_type_t JSON_Generator_State_type = {
625
624
  "JSON/Generator/State",
626
625
  {NULL, State_free, State_memsize,},
627
626
  #ifdef RUBY_TYPED_FREE_IMMEDIATELY
628
627
  0, 0,
629
- RUBY_TYPED_FREE_IMMEDIATELY,
628
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
630
629
  #endif
631
630
  };
632
631
  #endif
@@ -944,7 +943,7 @@ static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_S
944
943
  fbuffer_append_char(buffer, '"');
945
944
  #ifdef HAVE_RUBY_ENCODING_H
946
945
  if (!enc_utf8_compatible_p(rb_enc_get(obj))) {
947
- obj = rb_str_encode(obj, CEncoding_UTF_8, 0, Qnil);
946
+ obj = rb_str_export_to_enc(obj, rb_utf8_encoding());
948
947
  }
949
948
  #endif
950
949
  if (state->ascii_only) {
@@ -1166,8 +1165,7 @@ static VALUE cState_from_state_s(VALUE self, VALUE opts)
1166
1165
  } else if (rb_obj_is_kind_of(opts, rb_cHash)) {
1167
1166
  return rb_funcall(self, i_new, 1, opts);
1168
1167
  } else {
1169
- VALUE prototype = rb_const_get(mJSON, i_SAFE_STATE_PROTOTYPE);
1170
- return rb_funcall(prototype, i_dup, 0);
1168
+ return rb_class_new_instance(0, NULL, cState);
1171
1169
  }
1172
1170
  }
1173
1171
 
@@ -1499,6 +1497,10 @@ static VALUE cState_buffer_initial_length_set(VALUE self, VALUE buffer_initial_l
1499
1497
  */
1500
1498
  void Init_generator(void)
1501
1499
  {
1500
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
1501
+ rb_ext_ractor_safe(true);
1502
+ #endif
1503
+
1502
1504
  #undef rb_intern
1503
1505
  rb_require("json/common");
1504
1506
 
@@ -1603,10 +1605,4 @@ void Init_generator(void)
1603
1605
  i_match = rb_intern("match");
1604
1606
  i_keys = rb_intern("keys");
1605
1607
  i_dup = rb_intern("dup");
1606
- #ifdef HAVE_RUBY_ENCODING_H
1607
- CEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8"));
1608
- i_encoding = rb_intern("encoding");
1609
- i_encode = rb_intern("encode");
1610
- #endif
1611
- i_SAFE_STATE_PROTOTYPE = rb_intern("SAFE_STATE_PROTOTYPE");
1612
1608
  }
@@ -2,6 +2,7 @@
2
2
  require 'mkmf'
3
3
 
4
4
  have_func("rb_enc_raise", "ruby.h")
5
+ have_func("rb_enc_interned_str", "ruby.h")
5
6
 
6
7
  # checking if String#-@ (str_uminus) dedupes... '
7
8
  begin