Skip to content

v3.0.0

Latest

Choose a tag to compare

@byroot byroot released this 07 Sep 06:58

With the removal of the insecure create_additions option, JSON.load and JSON.dump are now safe to use. Them being unsafe by default caused multiple security vulnerabilites in the past.

If you did depend on create_additions, the recommended migration is to implement a custom serializer using JSON::Coder.

All the mutable default options, such as JSON.load_default_options have been removed. They were preventing Ractor compatiblity, and causing bug in libraries using JSON expecting the default behavior. JSON methods now always behave the same unless monkey patched.

All methods options are now either keyword arguments or checked like keyword arguments, meaning unknown options such as typos raise ArgumentError.

Duplicated keys are now rejected by default.

JavaScript comments in documents are no longer supported by default.

Numerous rarely used aliases have been removed.

  • Add JSON::ParserError#json_path to locate parse errors in the document as a JSONPath-style string (e.g. $.foo[0].bar). For duplicate key errors it points at the duplicated key itself.
  • Fix the parser to also reject lone trailing UTF-16 surrogates (\uDCxx with no leading partner), symmetric to the leading-surrogate case. The Java parser already rejected these; this closes the CRuby/JRuby parity gap.
  • JSON.load defaults are now safe to use.
  • All unknown options will now cause an ArgumentError rather than to be ignored.
  • The allow_comments parsing option now defaults to false.
  • The allow_duplicate_key option now defaults to false, for both parsing and generating JSON.
  • Removed the limit positional argument of JSON.dump.
  • Removed the escape_slash alias of script_safe.
  • Removed Kernel#j and Kernel#jj.
  • Removed JSON.load_default_options.
  • Removed JSON.unsafe_load_default_options.
  • Removed JSON.dump_default_options.
  • Removed JSON::State#[] and JSON::State#[]=.
  • Removed JSON.unparse.
  • Removed JSON.fast_generate.
  • Removed JSON.fast_unparse.
  • Removed JSON.pretty_unparse.
  • Removed JSON.restore.
  • Removed JSON::PRETTY_STATE_PROTOTYPE.
  • Removed the insecure create_additions option.
  • Removed JSON::GenericObject.

Full Changelog: v2.21.2...v3.0.0