Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
### 2025-04-24 (2.11.1)

* 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
These were deprecated 16 years ago, but never emitted warnings, only undocumented, so are
still used by a few gems.

### 2025-04-24 (2.11.0)
Expand All @@ -71,7 +71,7 @@
### 2025-03-12 (2.10.2)

* Fix a potential crash in the C extension parser.
* Raise a ParserError on all incomplete unicode escape sequence. This was the behavior until `2.10.0` unadvertently changed it.
* Raise a ParserError on all incomplete unicode escape sequence. This was the behavior until `2.10.0` inadvertently changed it.
* Ensure document snippets that are included in parser errors don't include truncated multibyte characters.
* Ensure parser error snippets are valid UTF-8.
* Fix `JSON::GeneratorError#detailed_message` on Ruby < 3.2
Expand Down Expand Up @@ -102,23 +102,23 @@

### 2024-11-14 (2.8.2)

* `JSON.load_file` explictly read the file as UTF-8.
* `JSON.load_file` explicitly read the file as UTF-8.

### 2024-11-06 (2.8.1)

* Fix the java packages to include the extension.

### 2024-11-06 (2.8.0)

* Emit a deprecation warning when `JSON.load` create custom types without the `create_additions` option being explictly enabled.
* Emit a deprecation warning when `JSON.load` create custom types without the `create_additions` option being explicitly 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.
* `JSON.pretty_generate` no longer includes newlines inside empty object and arrays.

### 2024-11-04 (2.7.6)

Expand All @@ -135,13 +135,13 @@
* 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).
* Make `json_pure` Ractor compatible.
* Make `json_pure` Ractor compatible.

### 2024-10-24 (2.7.3)

* Numerous performance optimizations in `JSON.generate` and `JSON.dump` (up to 2 times faster).
* Limit the size of ParserError exception messages, only include up to 32 bytes of the unparseable source.
* Fix json-pure's `Object#to_json` to accept non state arguments
* Limit the size of ParserError exception messages, only include up to 32 bytes of the unparsable source.
* Fix json-pure's `Object#to_json` to accept non-state arguments.
* Fix multiline comment support in `json-pure`.
* Fix `JSON.parse` to no longer mutate the argument encoding when passed an ASCII-8BIT string.
* Fix `String#to_json` to raise on invalid encoding in `json-pure`.
Expand Down
4 changes: 2 additions & 2 deletions benchmark/encoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def benchmark_encoding(benchmark_name, ruby_obj, check_expected: true, except: [

# NB: Notes are based on ruby 3.3.4 (2024-07-09 revision be1089c8ec) +YJIT [arm64-darwin23]

# On the first two micro benchmarks, the limitting factor is the fixed cost of initializing the
# On the first two micro benchmarks, the limiting factor is the fixed cost of initializing the
# generator state. Since `JSON.generate` now lazily allocate the `State` object we're now ~10-20% faster
# than `Oj.dump`.
benchmark_encoding "small mixed", [1, "string", { a: 1, b: 2 }, [3, 4, 5]]
Expand All @@ -87,7 +87,7 @@ def benchmark_encoding(benchmark_name, ruby_obj, check_expected: true, except: [
# This benchmark spent the overwhelming majority of its time in `ruby_dtoa`. We rely on Ruby's implementation
# which uses a relatively old version of dtoa.c from David M. Gay.
# Oj in `compat` mode is ~10% slower than `json`, but in its default mode is noticeably faster here because
# it limits the precision of floats, breaking roundtriping. That's not something we should emulate.
# it limits the precision of floats, breaking roundtripping. That's not something we should emulate.
#
# Since a few years there are now much faster float to string implementations such as Ryu, Dragonbox, etc,
# but all these are implemented in C++11 or newer, making it hard if not impossible to include them.
Expand Down
4 changes: 2 additions & 2 deletions ext/json/ext/generator/generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ static inline FORCE_INLINE void search_flush(search_state *search)
{
// Do not remove this conditional without profiling, specifically escape-heavy text.
// escape_UTF8_char_basic will advance search->ptr and search->cursor (effectively a search_flush).
// For back-to-back characters that need to be escaped, specifcally for the SIMD code paths, this method
// will be called just before calling escape_UTF8_char_basic. There will be no characers to append for the
// For back-to-back characters that need to be escaped, specifically for the SIMD code paths, this method
// will be called just before calling escape_UTF8_char_basic. There will be no characters to append for the
// consecutive characters that need to be escaped. While the fbuffer_append is a no-op if
// nothing needs to be flushed, we can save a few memory references with this conditional.
if (search->ptr > search->cursor) {
Expand Down
2 changes: 1 addition & 1 deletion ext/json/ext/parser/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
break;
}

raise_parse_error("unreacheable: %s", state);
raise_parse_error("unreachable: %s", state);
}

static void json_ensure_eof(JSON_ParserState *state)
Expand Down
Loading
Loading