Skip to content

Releases: ruby/json

v2.10.1

12 Feb 11:12
Compare
Choose a tag to compare

What's Changed

  • Fix a compatibility issue with MultiJson.dump(obj, pretty: true) by @byroot in #749

Full Changelog: v2.10.0...v2.10.1

v2.10.0

10 Feb 11:05
Compare
Choose a tag to compare

What's Changed

  • strict: true now accept symbols as values. Previously they'd only be accepted as hash keys.
  • The C extension Parser has been entirely reimplemented from scratch.
  • Introduced JSON::Coder as a new API allowing to customize how non native types are serialized in a non-global way.
  • Introduced JSON::Fragment to allow assembling cached fragments in a safe way.
  • The Java implementation of the generator received many optimizations.

Full Changelog: v2.9.1...v2.10.0

v2.9.1

18 Dec 23:01
Compare
Choose a tag to compare

What's Changed

  • Add support for Solaris 10 which lacks strnlen()

v2.9.0

03 Dec 08:26
20b501a
Compare
Choose a tag to compare

What's Changed

  • Fix C implementation of script_safe escaping to not confuse some other 3 wide characters with \u2028 and \u2029.
    e.g. JSON.generate(["倩", "瀨"], script_safe: true) would generate the wrong JSON.
  • JSON.dump(object, some_io) now write into the IO in chunks while previously it would buffer the entire JSON before writing.
  • JSON::GeneratorError now has a #invalid_object attribute, making it easier to understand why an object tree cannot be serialized.
  • Numerous improvements to the JRuby extension.

Full Changelog: v2.8.2...v2.9.0

v2.8.2

14 Nov 13:58
Compare
Choose a tag to compare

What's Changed

  • JSON.load_file: explictly load the file as UTF-8

Full Changelog: v2.8.1...v2.8.2

v2.8.1

06 Nov 17:37
Compare
Choose a tag to compare
  • Fix the java version of the package to include the extension implementation. Only concerns JRuby.

Full Changelog: v2.8.0...v2.8.1

v2.8.0

06 Nov 16:08
b9c8024
Compare
Choose a tag to compare

What's Changed

  • Emit a deprecation warning when JSON.load create custom types without the create_additions option being explictly enabled.
    • Prefer to use JSON.unsafe_load(string) or JSON.load(string, create_additions: true).
  • Emit a deprecation warning when serializing valid UTF-8 strings encoded in ASCII_8BIT aka BINARY.
  • Bump required Ruby version to 2.7.
  • Add support for optionally parsing trailing commas, via allow_trailing_comma: true, which in cunjunction with the
    pre-existing support for comments, make it suitable to parse jsonc documents.
  • Many performance improvements to JSON.parse and JSON.load, up to 1.7x faster on real world documents.
  • Some minor performance improvements to JSON.dump and JSON.generate.
  • JSON.pretty_generate no longer include newline inside empty object and arrays.

Parsing performance

Parsing performance is improved by 50-70% on realistic benchmarks, and even more on micro-benchmarks: https://gist.github.com/casperisfine/cf4b3a0594fae24b7d0eb93daaf3841a

== Parsing activitypub.json (58160 bytes)
ruby 3.4.0dev (2024-11-06T07:59:09Z precompute-hash-wh.. 7943f98a8a) +YJIT +PRISM [arm64-darwin24]
Warming up --------------------------------------
          json 2.7.2   638.000 i/100ms
                  oj   798.000 i/100ms
          Oj::Parser   948.000 i/100ms
           rapidjson   631.000 i/100ms
Calculating -------------------------------------
          json 2.7.2      6.423k (± 1.3%) i/s  (155.70 μs/i) -     32.538k in   5.067149s
                  oj      7.989k (± 1.0%) i/s  (125.17 μs/i) -     40.698k in   5.094544s
          Oj::Parser      9.472k (± 1.3%) i/s  (105.58 μs/i) -     47.400k in   5.005119s
           rapidjson      6.354k (± 1.1%) i/s  (157.37 μs/i) -     32.181k in   5.064962s

Comparison:
          json 2.8.0:     9510.0 i/s
          Oj::Parser:     9471.9 i/s - same-ish: difference falls within error
                  oj:     7989.4 i/s - 1.19x  slower
          json 2.7.2:     6422.5 i/s - 1.48x  slower
           rapidjson:     6354.5 i/s - 1.50x  slower


== Parsing twitter.json (567916 bytes)
ruby 3.4.0dev (2024-11-06T07:59:09Z precompute-hash-wh.. 7943f98a8a) +YJIT +PRISM [arm64-darwin24]
Warming up --------------------------------------
          json 2.7.2    52.000 i/100ms
                  oj    64.000 i/100ms
          Oj::Parser    76.000 i/100ms
           rapidjson    57.000 i/100ms
Calculating -------------------------------------
          json 2.7.2    526.860 (± 3.8%) i/s    (1.90 ms/i) -      2.652k in   5.042680s
                  oj    631.234 (± 1.7%) i/s    (1.58 ms/i) -      3.200k in   5.070973s
          Oj::Parser    764.354 (± 3.5%) i/s    (1.31 ms/i) -      3.876k in   5.077736s
           rapidjson    579.085 (± 2.8%) i/s    (1.73 ms/i) -      2.907k in   5.024620s

Comparison:
          json 2.8.0:      884.0 i/s
          Oj::Parser:      764.4 i/s - 1.16x  slower
                  oj:      631.2 i/s - 1.40x  slower
           rapidjson:      579.1 i/s - 1.53x  slower
          json 2.7.2:      526.9 i/s - 1.68x  slower


== Parsing citm_catalog.json (1727030 bytes)
ruby 3.4.0dev (2024-11-06T07:59:09Z precompute-hash-wh.. 7943f98a8a) +YJIT +PRISM [arm64-darwin24]
Warming up --------------------------------------
          json 2.7.2    30.000 i/100ms
                  oj    35.000 i/100ms
          Oj::Parser    45.000 i/100ms
           rapidjson    40.000 i/100ms
Calculating -------------------------------------
          json 2.7.2    304.584 (± 3.3%) i/s    (3.28 ms/i) -      1.530k in   5.029021s
                  oj    358.572 (± 0.8%) i/s    (2.79 ms/i) -      1.820k in   5.076123s
          Oj::Parser    450.643 (± 3.1%) i/s    (2.22 ms/i) -      2.295k in   5.098150s
           rapidjson    395.304 (± 1.5%) i/s    (2.53 ms/i) -      2.000k in   5.060537s

Comparison:
          json 2.8.0:      449.8 i/s
          Oj::Parser:      450.6 i/s - same-ish: difference falls within error
           rapidjson:      395.3 i/s - 1.14x  slower
                  oj:      358.6 i/s - 1.25x  slower
          json 2.7.2:      304.6 i/s - 1.48x  slower

Full Changelog: v2.7.3...v2.8.0

v2.7.6

04 Nov 13:28
Compare
Choose a tag to compare
  • Fix a regression in JSON.generate when dealing with Hash keys that are string subclasses, call to_json on them.

Full Changelog: v2.7.5...v2.7.6

v2.7.5

30 Oct 11:18
9d71186
Compare
Choose a tag to compare

What's Changed

  • Fix a memory leak when #to_json methods raise an exception.
  • Gracefully handle formatting configs being set to nil instead of "".
  • Workaround another issue caused by conflicting versions of both json_pure and json being loaded.

Full Changelog: v2.7.4...v2.7.5

v2.7.4

25 Oct 11:12
9e9b749
Compare
Choose a tag to compare

What's Changed

  • Workaround a bug in 3.4.8 and older rubygems/rubygems#6490.
    This bug would cause some gems with native extension to fail during compilation.
  • Workaround different versions of json and json_pure being loaded (not officially supported).
  • Make json_pure Ractor compatible.

Full Changelog: v2.7.3...v2.7.4