summaryrefslogtreecommitdiff
path: root/ext/json/lib
AgeCommit message (Collapse)Author
2025-04-15[ruby/json] Deprecate Kernel#j and Kernel#jjJean Boussier
https://github.com/ruby/json/commit/27155b6500
2025-04-15[ruby/json] Get rid of JSONError.wrapJean Boussier
https://github.com/ruby/json/commit/3e7e661ef5
2025-04-15[ruby/json] Don't create custom NaN and Infinity objects.Jean Boussier
https://github.com/ruby/json/commit/ff8e18392d
2025-03-28[ruby/json] Move `create_addtions` logic in Ruby.Jean Boussier
By leveraging the `on_load` callback we can move all this logic out of the parser. Which mean we no longer have to duplicate that logic in both parser and that we'll later be able to extract it entirely from the gem. https://github.com/ruby/json/commit/f411ddf1ce Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-28[ruby/json] JSON.load invoke the proc callback directly from the parser.Jean Boussier
And substitute the return value like `Marshal.load` doesm which I can only assume was the intent. This also open the door to re-implement all the `create_addition` logic in `json/common.rb`. https://github.com/ruby/json/commit/73d2137fd3 Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-28[ruby/json] Remove more dead codeJean Boussier
https://github.com/ruby/json/commit/eda239ad34 Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-28[ruby/json] Remove `Class#json_creatable?` monkey patch.Jean Boussier
https://github.com/ruby/json/commit/1ca7efed1f Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-28[ruby/json] Get rid of JSON::NOT_SETJean Boussier
https://github.com/ruby/json/commit/760d922265 Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-28[ruby/json] Remove outdated JSON.iconvJean Boussier
https://github.com/ruby/json/commit/3de8702354 Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-28[ruby/json] Cleanup JSON.pretty_generateJean Boussier
https://github.com/ruby/json/commit/01c47a0555 Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-28[ruby/json] Deprecate `JSON.fast_generate`Jean Boussier
https://github.com/ruby/json/commit/6508455d82 Notes: Merged: https://github.com/ruby/ruby/pull/13004
2025-03-27Get rid of SAFE_STATE_PROTOTYPEJean Boussier
It was only used by JRuby and TruffleRuby to call `SAFE_STATE_PROTOTYPE.dup` instead of `State.new` which isn't an worthy optimization. Notes: Merged: https://github.com/ruby/ruby/pull/12994
2025-03-27[ruby/json] Remove unused `FAST_STATE_PROTOTYPE` and `PRETTY_STATE_PROTOTYPE`Jean Boussier
https://github.com/ruby/json/commit/18e5c3c67c
2025-03-27[ruby/json] Remove `unparse` and `restore` aliases.Jean Boussier
These were deprecated 16 years ago. https://github.com/ruby/json/commit/a88d825a91
2025-03-27[ruby/json] Deprecate all `*_default_options`Jean Boussier
Globally changing the behavior of the library is a bad idea, as many different libraries may rely on `json` and may not expect it and likely never tested that a different default config works for them. If you need to change the behavior of JSON, it's best to do it only locally, and not globally. In addition the new `JSON::Coder` interface is much more suited for that. Another reason for the deprecation is that it's impossible to make `JSON.load` and `JSON.dump` Ractor-safe with such API. https://github.com/ruby/json/commit/172762c6e4
2025-03-13[ruby/json] Release 2.10.2Jean Boussier
https://github.com/ruby/json/commit/350c1fd154
2025-03-06[ruby/json] Fix JSON::GeneratorError#detailed_message with Ruby < 3.2Rahim Packir Saibo
https://github.com/ruby/json/commit/2e015ff839
2025-02-19[ruby/json] Pass through all options if present.Samuel Williams
https://github.com/ruby/json/commit/bea96e0a69
2025-02-12[ruby/json] Release 2.10.1Jean Boussier
https://github.com/ruby/json/commit/aa5b7d6acb
2025-02-12[ruby/json] Release 2.10.0Jean Boussier
https://github.com/ruby/json/commit/8b56d47254
2025-02-06Optimize Symbol generation in strict modeÉtienne Barrié
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2025-01-30[ruby/json] Few doc tweaks:Edouard CHIN
- Also modified the gemspec files' blob as the ragel's `parser.rl` file was removed in https://github.com/ruby/json/commit/c8d5236a921e https://github.com/ruby/json/commit/b2b106e314
2025-01-28Introduce JSON::CoderÉtienne Barrié
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2025-01-28[ruby/json] Add some JSON::Fragment documentationJean Boussier
https://github.com/ruby/json/commit/dbcf614e50
2025-01-20[ruby/json] Fix JSON::Fragment#to_json signatureJean Boussier
https://github.com/ruby/json/commit/f8817fe56c Notes: Merged: https://github.com/ruby/ruby/pull/12602
2025-01-20[ruby/json] Introduce JSON::FragmentÉtienne Barrié
https://github.com/ruby/json/commit/9e3500f345 Co-authored-by: Jean Boussier <jean.boussier@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/12602
2025-01-14[ruby/json] Fix a method redefinition warning in C parserJean Boussier
Ref: https://github.com/ruby/json/pull/728 Ref: https://github.com/ruby/ruby/pull/12569 https://github.com/ruby/json/commit/30a4a86954
2025-01-14[ruby/json] Refactor JSON::Ext::Parser to split configuration and parsing stateJean Boussier
Ref: https://github.com/ruby/json/pull/718 The existing `Parser` interface is pretty bad, as it forces to instantiate a new instance for each document. Instead it's preferable to only take the config and do all the initialization needed, and then keep the parsing state on the stack on in ephemeral memory. This refactor makes the `JSON::Coder` pull request much easier to implement in a performant way. https://github.com/ruby/json/commit/c8d5236a92 Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2025-01-14Remove Generator::State#_generateÉtienne Barrié
Co-authored-by: Jean Boussier <jean.boussier@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/12568
2024-12-19[ruby/json] Release 2.9.1Jean Boussier
https://github.com/ruby/json/commit/f745ec145e Notes: Merged: https://github.com/ruby/ruby/pull/12394
2024-12-05[ruby/json] Release 2.9.0Jean Boussier
https://github.com/ruby/json/commit/e1f6456499 Notes: Merged: https://github.com/ruby/ruby/pull/12267
2024-11-26JSON::GeneratorError expose invalid objectJean Boussier
Fix: https://github.com/ruby/json/issues/710 Makes it easier to debug why a given tree of objects can't be dumped as JSON. Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2024-11-26[ruby/json] JSON.dump: write directly into the provided IOJean Boussier
Ref: https://github.com/ruby/json/issues/524 Rather than to buffer everything in memory. Unfortunately Ruby doesn't provide an API to write into and IO without first allocating a string, which is a bit wasteful. https://github.com/ruby/json/commit/f017af6c0a
2024-11-18[ruby/json] Fix the BEWARE documentation in `load` and `unsafe_load`.Jean Boussier
https://github.com/ruby/json/commit/2d62ec449f Notes: Merged: https://github.com/ruby/ruby/pull/12103
2024-11-18[ruby/json] Release 2.8.2Jean Boussier
https://github.com/ruby/json/commit/d5e4a6e3fd Notes: Merged: https://github.com/ruby/ruby/pull/12103
2024-11-18[ruby/json] Fix redundant to_str callrazokulover
https://github.com/ruby/json/commit/61f022dfbd Notes: Merged: https://github.com/ruby/ruby/pull/12103
2024-11-11[ruby/json] JSON.load_file: explictly load the file as UTF-8Jean Boussier
Fix: https://github.com/ruby/json/issues/697 This way even if `Encoding.default_external` is set to a weird value the document will be parsed just fine. https://github.com/ruby/json/commit/3a8505a8fa
2024-11-11[ruby/json] Release 2.8.1Jean Boussier
https://github.com/ruby/json/commit/49650f7312
2024-11-06[ruby/json] Release 2.8.0Jean Boussier
https://github.com/ruby/json/commit/8071cc6f09
2024-11-05[ruby/json] ResyncJean Boussier
Notes: Merged: https://github.com/ruby/ruby/pull/12003
2024-11-01[ruby/json] Emit warnings when dumping binary stringsJean Boussier
Because of it's Ruby 1.8 heritage, the C extension doesn't care much about strings encoding. We should get stricter over time. https://github.com/ruby/json/commit/42402fc13f
2024-11-01Deprecate unsafe default options of `JSON.load`Jean Boussier
[Feature #19528] Ref: https://bugs.ruby-lang.org/issues/19528 `load` is understood as the default method for serializer kind of libraries, and the default options of `JSON.load` has caused many security vulnerabilities over the years. The plan is to do like YAML/Psych, deprecate these default options and direct users toward using `JSON.unsafe_load` so at least it's obvious it should be used against untrusted data.
2024-11-01Elide Generator::State allocation until a `to_json` method has to be calledJean Boussier
Fix: https://github.com/ruby/json/issues/655 For very small documents, the biggest performance gap with alternatives is that the API impose that we allocate the `State` object. In a real world app this doesn't make much of a difference, but when running in a micro-benchmark this doubles the allocations, causing twice the amount of GC runs, making us look bad. However, unless we have to call a `to_json` method, the `State` object isn't visible, so with some refactoring, we can elude that allocation entirely. Instead we allocate the State internal struct on the stack, and if we need to call a `to_json` method, we allocate the `State` and spill the struct on the heap. As a result, `JSON.generate` is now as fast as re-using a `State` instance, as long as only primitives are generated. Before: ``` == Encoding small mixed (34 bytes) ruby 3.3.4 (2024-07-09 revision be1089c8ec) +YJIT [arm64-darwin23] Warming up -------------------------------------- json (reuse) 598.654k i/100ms json 400.542k i/100ms oj 533.353k i/100ms Calculating ------------------------------------- json (reuse) 6.371M (± 8.6%) i/s (156.96 ns/i) - 31.729M in 5.059195s json 4.120M (± 6.6%) i/s (242.72 ns/i) - 20.828M in 5.090549s oj 5.622M (± 6.4%) i/s (177.86 ns/i) - 28.268M in 5.061473s Comparison: json (reuse): 6371126.6 i/s oj: 5622452.0 i/s - same-ish: difference falls within error json: 4119991.1 i/s - 1.55x slower == Encoding small nested array (121 bytes) ruby 3.3.4 (2024-07-09 revision be1089c8ec) +YJIT [arm64-darwin23] Warming up -------------------------------------- json (reuse) 248.125k i/100ms json 215.255k i/100ms oj 217.531k i/100ms Calculating ------------------------------------- json (reuse) 2.628M (± 6.1%) i/s (380.55 ns/i) - 13.151M in 5.030281s json 2.185M (± 6.7%) i/s (457.74 ns/i) - 10.978M in 5.057655s oj 2.217M (± 6.7%) i/s (451.10 ns/i) - 11.094M in 5.044844s Comparison: json (reuse): 2627799.4 i/s oj: 2216824.8 i/s - 1.19x slower json: 2184669.5 i/s - 1.20x slower == Encoding small hash (65 bytes) ruby 3.3.4 (2024-07-09 revision be1089c8ec) +YJIT [arm64-darwin23] Warming up -------------------------------------- json (reuse) 641.334k i/100ms json 322.745k i/100ms oj 642.450k i/100ms Calculating ------------------------------------- json (reuse) 7.133M (± 6.5%) i/s (140.19 ns/i) - 35.915M in 5.068201s json 4.615M (± 7.0%) i/s (216.70 ns/i) - 22.915M in 5.003718s oj 6.912M (± 6.4%) i/s (144.68 ns/i) - 34.692M in 5.047690s Comparison: json (reuse): 7133123.3 i/s oj: 6911977.1 i/s - same-ish: difference falls within error json: 4614696.6 i/s - 1.55x slower ``` After: ``` == Encoding small mixed (34 bytes) ruby 3.3.4 (2024-07-09 revision be1089c8ec) +YJIT [arm64-darwin23] Warming up -------------------------------------- json (reuse) 572.751k i/100ms json 457.741k i/100ms oj 512.247k i/100ms Calculating ------------------------------------- json (reuse) 6.324M (± 6.9%) i/s (158.12 ns/i) - 31.501M in 5.023093s json 6.263M (± 6.9%) i/s (159.66 ns/i) - 31.126M in 5.017086s oj 5.569M (± 6.6%) i/s (179.56 ns/i) - 27.661M in 5.003739s Comparison: json (reuse): 6324183.5 i/s json: 6263204.9 i/s - same-ish: difference falls within error oj: 5569049.2 i/s - same-ish: difference falls within error == Encoding small nested array (121 bytes) ruby 3.3.4 (2024-07-09 revision be1089c8ec) +YJIT [arm64-darwin23] Warming up -------------------------------------- json (reuse) 258.505k i/100ms json 242.335k i/100ms oj 220.678k i/100ms Calculating ------------------------------------- json (reuse) 2.589M (± 9.6%) i/s (386.17 ns/i) - 12.925M in 5.071853s json 2.594M (± 6.6%) i/s (385.46 ns/i) - 13.086M in 5.083035s oj 2.250M (± 2.3%) i/s (444.43 ns/i) - 11.255M in 5.004707s Comparison: json (reuse): 2589499.6 i/s json: 2594321.0 i/s - same-ish: difference falls within error oj: 2250064.0 i/s - 1.15x slower == Encoding small hash (65 bytes) ruby 3.3.4 (2024-07-09 revision be1089c8ec) +YJIT [arm64-darwin23] Warming up -------------------------------------- json (reuse) 656.373k i/100ms json 644.135k i/100ms oj 650.283k i/100ms Calculating ------------------------------------- json (reuse) 7.202M (± 7.1%) i/s (138.84 ns/i) - 36.101M in 5.051438s json 7.278M (± 1.7%) i/s (137.40 ns/i) - 36.716M in 5.046300s oj 7.036M (± 1.7%) i/s (142.12 ns/i) - 35.766M in 5.084729s Comparison: json (reuse): 7202447.9 i/s json: 7277883.0 i/s - same-ish: difference falls within error oj: 7036115.2 i/s - same-ish: difference falls within error ```
2024-10-26[ruby/json] Instantiate Parser with a kwsplatJean Boussier
Prior to 2.7.3, `JSON::Ext::Parser` would only take kwargs. So if json_pure 2.7.4 is loaded with `json <= 2.7.2` (or stdlib) it blows up. Ref: https://github.com/ruby/json/issues/650 Fix: https://github.com/ruby/json/issues/651 https://github.com/ruby/json/commit/4d9dc98817
2024-10-26[ruby/json] Workaround being loaded alongside a different `json_pure` versionJean Boussier
Fix: https://github.com/ruby/json/issues/646 Since both `json` and `json_pure` expose the same files, if the versions don't match, the native extension may be loaded with Ruby code that don't match and is incompatible. By doing the `require json/ext/generator/state` from C we ensure we're at least loading that. But this is a dirty workaround for the 2.7.x branch, we should find a better way to fully isolate the two gems. https://github.com/ruby/json/commit/dfdd4acf36
2024-10-26[ruby/json] Modernize heredocsJean Boussier
https://github.com/ruby/json/commit/fb25e94aea
2024-10-26[ruby/json] Start 2.8.0 developmentJean Boussier
https://github.com/ruby/json/commit/937c8d2e65
2024-10-26[ruby/json] Release 2.7.3Jean Boussier
https://github.com/ruby/json/commit/7a3b482013
2024-10-26[ruby/json] Release 2.7.3.rc1Jean Boussier
https://github.com/ruby/json/commit/a48be35825
2024-10-26Use frozen string literalsÉtienne Barrié
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>