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.
Add back JSON.restore, JSON.unparse, JSON.fast_unparse and JSON.pretty_unparse.
These were deprecated 16 years ago, but never emited warnings, only undocumented, so are
still used by a few gems.
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.
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.
Workaround a bug in 3.4.8 and older https://github.com/rubygems/rubygems/pull/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).
Fix default of create_additions to always be false for JSON(user_input)
and JSON.parse(user_input, nil).
Note that JSON.load remains with default true and is meant for internal
serialization of trusted data. [CVE-2020-10663]
Implements compatibility to ruby 2.4 integer unification.
Drops support for old rubies whose life has ended, that is rubies < 2.0.
Also see https://www.ruby-lang.org/en/news/2014/07/01/eol-for-1-8-7-and-1-9-2/
There were still some mentions of dual GPL licensing in the source, but JSON
has just the Ruby license that itself includes an explicit dual-licensing
clause that allows covered software to be distributed under the terms of
the Simplified BSD License instead for all ruby versions >= 1.9.3. This is
however a GPL compatible license according to the Free Software Foundation.
I changed these mentions to be consistent with the Ruby license setting in
the gemspec files which were already correct now.
There were still some mentions of dual GPL licensing in the source, but JSON
has just the Ruby license that itself includes an explicit dual-licensing
clause that allows covered software to be distributed under the terms of
the Simplified BSD License instead for all ruby versions >= 1.9.3. This is
however a GPL compatible license according to the Free Software Foundation.
I changed these mentions to be consistent with the Ruby license setting in
the gemspec files which were already correct now.
Fix https://github.com/ruby/json/issues/162 reported by Marc-Andre
Lafortune github_rocks@marc-andre.ca. Thanks!
Applied patches by Yui NARUSE naruse@airemix.jp to suppress warning with
-Wchar-subscripts and better validate UTF-8 strings.
Applied patch by ginriki@github to remove unnecessary if.
Add load/dump interface to JSON::GenericObject to make
serialize :some_attribute, JSON::GenericObject
work in Rails active models for convenient SomeModel#some_attribute.foo.bar
access to serialised JSON data.
Security fix for JSON create_additions default value and
JSON::GenericObject. It should not be possible to create additions unless
explicitly requested by setting the create_additions argument to true or
using the JSON.load/dump interface. If JSON::GenericObject is supposed to
be automatically deserialised, this has to be explicitly enabled by
setting
JSON::GenericObject.json_creatable = true
as well.
Remove useless assert in fbuffer implementation.
Apply patch attached to https://github.com/ruby/json/issues#issue/155
provided by John Shahid jvshahid@gmail.com, Thx!
Add license information to rubygems spec data, reported by Jordi Massaguer Pla jmassaguerpla@suse.de.
Propagate src encoding to values made from it (fixes 1.9 mode converting
everything to ascii-8bit; harmless for 1.8 mode too) (Thomas E. Enebo
tom.enebo@gmail.com), should fix
https://github.com/ruby/json/issues#issue/119.
Fix https://github.com/ruby/json/issues#issue/124 Thx to Jason Hutchens.
Vit Ondruch v.ondruch@tiscali.cz reported a bug that shows up when using
optimisation under GCC 4.7. Thx to him, Bohuslav Kabrda
bkabrda@redhat.com and Yui NARUSE naruse@airemix.jp for debugging and
developing a patch fix.
Make JSON.dump and JSON.load methods better cooperate with Rails' serialize
method. Just use:
serialize :value, JSON
Fix bug with time serialization concerning nanoseconds. Thanks for the
patch go to Josh Partlow (jpartlow@github).
Improve parsing speed for JSON numbers (integers and floats) in a similar way to
what Evan Phoenix evan@phx.io suggested in:
https://github.com/ruby/json/pull/103
Manage data structure nesting depth in state object during generation. This
should reduce problems with to_json method definіtions that only have one
argument.
Some fixes in the state objects and additional tests.
fast_generate now raises an exception for nan and infinite floats.
On Ruby 1.8 json supports parsing of UTF-8, UTF-16BE, UTF-16LE, UTF-32BE,
and UTF-32LE JSON documents now. Under Ruby 1.9 the M17n conversion
functions are used to convert from all supported encodings. ASCII-8BIT
encoded strings are handled like all strings under Ruby 1.8 were.
Applied a patch by OZAWA Sakuro sakuro@2238club.org to make json/pure
work in environments that don't provide iconv.
Applied patch by okkez_ in order to fix Ruby Bug #1768:
http://redmine.ruby-lang.org/issues/show/1768.
Finally got around to avoid the rather paranoid escaping of ?/ characters
in the generator's output. The parsers aren't affected by this change.
Thanks to Rich Apodaca rapodaca@metamolecular.com for the suggestion.
Security Fix for JSON::Pure::Parser. A specially designed string could
cause catastrophic backtracking in one of the parser's regular expressions
in earlier 1.1.x versions. JSON::Ext::Parser isn't affected by this issue.
Thanks to Bartosz Blimke bartosz@new-bamboo.co.uk for reporting this
problem.
This release also uses a less strict ruby version requirement for the
creation of the mswin32 native gem.
No changes. І tested native linux gems in the last release and they don't
play well with different ruby versions other than the one the gem was built
with. This release is just to bump the version number in order to skip the
native gem on rubyforge.
Wesley Beary monki@geemus.com reported a bug in json/add/core's DateTime
handling: If the nominator and denominator of the offset were divisible by
each other Ruby's Rational#to_s returns them as an integer not a fraction
with '/'. This caused a ZeroDivisionError during parsing.
Use Date#start and DateTime#start instead of sg method, while
remaining backwards compatible.
Remember default dir (last used directory) in editor.
JSON::Editor.edit method added, the editor can now receive json texts from
the clipboard via C-v.
Load json texts from an URL pasted via middle button press.
Added :create_additions option to Parser. This makes it possible to disable
the creation of additions by force, in order to treat json texts as data
while having additions loaded.
Jacob Maine jmaine@blurb.com reported, that JSON(:foo) outputs a JSON
object if the rails addition is enabled, which is wrong. It now outputs a
JSON string "foo" instead, like suggested by Jacob Maine.
Discovered a bug in the Ruby Bugs Tracker on rubyforge, that was reported
by John Evans lgastako@gmail.com. He could produce a crash in the JSON
generator by returning something other than a String instance from a
to_json method. I now guard against this by doing a rather crude type
check, which raises an exception instead of crashing.
Yui NARUSE naruse@airemix.com sent some patches to fix tests for Ruby
1.9. I applied them and adapted some of them a bit to run both on 1.8 and
1.9.
Introduced a JSON.parse! method without depth checking for people who
like danger.
Made generate and pretty_generate methods configurable by an options hash.
Added :allow_nan option to parser and generator in order to handle NaN,
Infinity, and -Infinity correctly - if requested. Floats, which aren't numbers,
aren't valid JSON according to RFC4627, so by default an exception will be
raised if any of these symbols are encountered. Thanks to Andrea Censi
andrea.censi@dis.uniroma1.it for his hint about this.
Fixed some more tests for Ruby 1.9.
Implemented dump/load interface of Marshal as suggested in ruby-core:11405
by murphy murphy@rubychan.de.
Implemented the max_nesting feature for generate methods, too.
Added some implementations for ruby core's custom objects for
serialisation/deserialisation purposes.
Implemented max_nesting feature for parser to avoid stack overflows for
data from untrusted sources. If you trust the source, you can disable it
with the option max_nesting => false.
Piers Cawley pdcawley@bofh.org.uk reported a bug, that not every
character can be escaped by \ as required by RFC4627. There's a
contradiction between David Crockford's JSON checker test vectors (in
tests/fixtures) and RFC4627, though. I decided to stick to the RFC, because
the JSON checker seems to be a bit older than the RFC.
Extended license to Ruby License, which includes the GPL.
Added keyboard shortcuts, and 'Open location' menu item to edit_json.rb.
Applied a patch from Yui NARUSE naruse@airemix.com to make JSON compile
under Ruby 1.9. Thank you very much for mailing it to me!
Made binary variants of JSON fail early, instead of falling back to the
pure version. This should avoid overshadowing of eventual problems while
loading of the binary.
Conform more to RFC4627 for JSON: This means JSON strings
now always must contain exactly one object "{ ... }" or array "[ ... ]" in
order to be parsed without raising an exception. The definition of what
constitutes a whitespace is narrower in JSON than in Ruby ([ \t\r\n]), and
there are differences in floats and integers (no octals or hexadecimals) as
well.
Added aliases generate and pretty_generate of unparse and pretty_unparse.
Fixed a test case.
Catch an Iconv::InvalidEncoding exception, that seems to occur on some Sun
boxes with SunOS 5.8, if iconv doesn't support utf16 conversions. This was
reported by Andrew R Jackson andrewj@bcm.tmc.edu, thanks a bunch!