Skip to content

Releases: ruby/json

v2.17.0

03 Dec 15:25

Choose a tag to compare

What's Changed

  • Improve JSON.load and JSON.unsafe_load to allow passing options as second argument.
  • Fix the parser to no longer ignore invalid escapes in strings.
    Only \", \\, \b, \f, \n, \r, \t and \u are valid JSON escapes.
  • Fixed JSON::Coder to use the depth it was initialized with.
  • On TruffleRuby, fix the generator to not call to_json on the return value of as_json for Float::NAN.
  • Fixed handling of state.depth: when to_json changes state.depth but does not restore it, it is reset
    automatically to its initial value.
    In particular, when a NestingError is raised, depth is no longer equal to max_nesting after the call to
    generate, and is reset to its initial value. Similarly when to_json raises an exception.

Full Changelog: v2.16.0...v2.17.0

v2.16.0

07 Nov 09:14

Choose a tag to compare

What's Changed

  • Deprecate JSON::State#[] and JSON::State#[]=. Consider using JSON::Coder instead.
  • JSON::Coder now also yields to the block when encountering strings with invalid encoding.
  • Fix GeneratorError messages to be UTF-8 encoded.
  • Fix memory leak when Exception is raised, or throw is used during JSON generation.
  • Optimized floating point number parsing by integrating the ryu algorithm (thanks to Josef Ε imΓ‘nek).
  • Optimized numbers parsing using SWAR (thanks to Scott Myron).
  • Optimized parsing of pretty printed documents using SWAR (thanks to Scott Myron).

Full Changelog: v2.15.2...v2.16.0

v2.15.2

25 Oct 09:00

Choose a tag to compare

What's Changed

  • Fix JSON::Coder to have one dedicated depth counter per invocation.
    After encountering a circular reference in JSON::Coder#dump, any further #dump call would raise JSON::NestingError.

Full Changelog: v2.15.1...v2.15.2

v2.15.1

07 Oct 08:32

Choose a tag to compare

What's Changed

  • Fix incorrect escaping in the JRuby extension when encoding shared strings.

Full Changelog: v2.15.0...v2.15.1

v2.15.0

22 Sep 10:05

Choose a tag to compare

What's Changed

  • JSON::Coder callback now receive a second argument to convey whether the object is a hash key.
  • Tuned the floating point number generator to not use scientific notation as aggressively.

Full Changelog: v2.14.1...v2.15.0

v2.14.1

18 Sep 14:32

Choose a tag to compare

What's Changed

  • Fix IndexOutOfBoundsException in the JRuby extension when encoding shared strings.

Full Changelog: v2.14.0...v2.14.1

v2.14.0

18 Sep 09:29

Choose a tag to compare

What's Changed

  • Add new allow_duplicate_key generator options. By default a warning is now emitted when a duplicated key is encountered.
    In json 3.0 an error will be raised.
    >> Warning[:deprecated] = true
    >> puts JSON.generate({ foo: 1, "foo" => 2 })
    (irb):2: warning: detected duplicate key "foo" in {foo: 1, "foo" => 2}.
    This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
    {"foo":1,"foo":2}
    >> JSON.generate({ foo: 1, "foo" => 2 }, allow_duplicate_key: false)
    detected duplicate key "foo" in {foo: 1, "foo" => 2} (JSON::GeneratorError)
  • Fix JSON.generate strict: true mode to also restrict hash keys.
  • Fix JSON::Coder to also invoke block for hash keys that aren't strings nor symbols.
  • Fix JSON.unsafe_load usage with proc
  • Fix the parser to more consistently reject invalid UTF-16 surogate pairs.
  • Stop defining String.json_create, String#to_json_raw, String#to_json_raw_object when json/add isn't loaded.

Full Changelog: v2.13.2...v2.14.0

v2.13.2

28 Jul 07:05

Choose a tag to compare

What's Changed

  • Improve duplicate key warning and errors to include the key name and point to the right caller.

Full Changelog: v2.13.1...v2.13.2

v2.13.1

24 Jul 12:09

Choose a tag to compare

What's Changed

  • Fix support for older compilers without __builtin_cpu_supports.

Full Changelog: v2.13.0...v2.13.1

v2.13.0

17 Jul 08:29

Choose a tag to compare

What's Changed

  • Add new allow_duplicate_key parsing options. By default a warning is now emitted when a duplicated key is encountered.
    In json 3.0 an error will be raised.
  • Optimize parsing further using SIMD to scan strings.

Full Changelog: v2.12.2...v2.13.0