8 Commits
Author SHA1 Message Date
Étienne Barrié 2f192c73cc [ruby/json] Respect Coder depth when generating
https://github.com/ruby/json/commit/9c36681b17
2025-11-27 13:01:57 +00:00
Étienne Barrié 78aa8d5b1d [ruby/json] Test current behavior regarding depth for Coder
Coder currently ignores its depth and always resets it to 0 when
generating a new JSON document.

https://github.com/ruby/json/commit/cca1f38316
2025-11-27 13:01:56 +00:00
Jean Boussier 5153a2dcb3 [ruby/json] Invoke as_json callback for strings with invalid encoding
Fix: https://github.com/ruby/json/issues/873

This allow users to encode binary strings if they so wish.
e.g. they can use Base64 or similar, or chose to replace invalid
characters with something else.

https://github.com/ruby/json/commit/b1b16c416f
2025-11-02 14:48:33 +00:00
Jean Boussier 8e8e327870 [ruby/json] Fix concurrent usage of JSON::Coder#dump
Fix: https://github.com/rails/rails/commit/90616277e3d8fc46c9cf35d6a7470ff1ea0092f7#r168784389

Because the `depth` counter is inside `JSON::State` it can't be used
concurrently, and in case of a circular reference the counter may be
left at the max value.

The depth counter should be moved outside `JSON_Generator_State` and
into `struct generate_json_data`, but it's a larger refactor.

In the meantime, `JSON::Coder` calls `State#generate_new` so I changed
that method so that it first copy the state on the stack.

https://github.com/ruby/json/commit/aefa671eca
2025-10-25 08:57:48 +00:00
Jean Boussier 1042a0bdd8 JSON::Coder callback now recieve a second argument to mark object keys
e.g.
```ruby
{ 1 => 2 }
```

The callback will be invoked for `1` as while it has a native JSON
equivalent, it's not legal as an object name.
2025-09-19 19:30:10 +09:00
Jean Boussier 0e0f0dfd07 Fix JSON::Coder to cast non-string keys. 2025-08-27 10:01:52 +09:00
Étienne BarriéandJean Boussier f865148e19 Fix JSON::Coder to call as_json proc for NaN and Infinity
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2025-02-06 16:02:03 +09:00
Étienne BarriéandJean Boussier 89e316ad06 Introduce JSON::Coder
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2025-01-28 15:41:47 +09:00