Repository navigation
Changes
-
Minimum Rust version (MSRV) is now 1.91.0
-
JsonStreamReaderdoes not perform any buffering anymore
Depending on the use case astd::io::BufReadershould be used, for example when reading from a file or a network connection. -
(Breaking) Removed
JsonStreamReader::reader_mut
(The internal implementation usesstd::io::Bytesnow, and that does not support obtaining a reference to the underlyingRead) -
(Breaking) Refactored reader and writer error types
ReaderErrorlocationis now common to allReaderErrorvariants- fields are now private; public methods are provided to get access to its data
- reduced stack size of
ReaderError
- removed the separate
JsonSyntaxErrorstruct - converted some tuple structs to structs with fields to make it clearer what the contained data represents
-
(Breaking) Improved settings for multiple top-level values for JSON reader and writer
-
(Breaking) Clarified that generally reader errors are not safe to retry, regardless of kind
Previously the documentation saidUnexpectedValueTypeandUnexpectedStructurewere safe to retry in most cases, but the list of exclusions was incomplete. And in general these two errors can be avoided by usingpeek()respectivelyhas_next(). -
(New) Added
JsonReader::next_number_int
New experimental method for reading integer numbers more efficiently thanJsonReader::next_number. Please provide feedback in #167. -
(New) Added
JsonReader::deserialize_next_recoverable
New experimental method which supports recovering from some errors. Please provide feedback in #180. -
(New) Added support for reading and writing empty JSON documents
Disabled by default; can be enabled withallow_empty_documentfield of reader and writer settings.
Useful when producing or consuming potentially empty JSON Lines documents. -
(New) Added convenience method
is_io()to reader-related errors
Can be useful for determining whether an error is caused by an IO error from the underlying reader, or due to invalid or malformed JSON data. -
(New) Added a dedicated reader error kind for invalid UTF-8 data
Previously it was reported as IO error. -
(New) Added
JsonReader::previous_json_pathand newdisplay_json_path
Can be used for better error reporting when enforcing additional constraints for a JSON value after it has been read, for example that a JSON string value must match a certain pattern. -
(New) Added
NumberFormattertrait
New experimental trait which supports customizing how JSON numbers are formatted for a JSON writer. Please provide feedback in #184. -
(New) Added opt-in detection of duplicate member names when reading (thanks @HardMax71!)
Disabled by default; can be enabled with the newReaderSettings::duplicate_name_detection.
Simple API
-
(New) Added
ValueReader::read_deserialize_recoverable
New experimental method which supports recovering from some errors. Please provide feedback in #180. -
(Breaking)
ValueReader::read_string_with_readermust now fully consume the JSON string
No implicit skipping of the remainder of the value is performed anymore. The new methodStringValueReader::skip_remaindercan be used to explicitly skip the remainder (if any).
Custom JsonReader & JsonWriter
These changes are most likely only relevant when implementing a custom JsonReader or JsonWriter.
- Added default implementations for
JsonReader::deserialize_next,JsonReader::transfer_toJsonWriter::serialize_value
Minor changes
These changes are probably not noticeable to most users.
-
[Simple API] For
read_string_with_readerdon't redundantly wrap the underlying error fromJsonStreamReader -
[Simple API] Improved error message for string value reader
-
[Simple API] Fixed when errors were repeated after a previous error, some of them did not indicate that they represent a previous error
-
Added
Debugas supertrait forFiniteNumberandFloatingPointNumber -
Fixed wrong panic messages when using
JsonStreamWriterincorrectly -
Improved string writing performance for
JsonStreamWriterwith default settings -
Changed display format of JSON paths in errors to use the format of the JSONPath standard
However, this is an implementation detail and the format may change in the future, see thedisplay_json_pathfunction for details. -
Removed
From<std::io::Error>forTransferError::WriterError
This was error-prone because the IO error could have also originated from the JSON reader, not the writer. So the choice whichTransferErrorvariant to construct should be explicit. -
Updated Serde integration behavior to match serde_json 1.0.150
In particular, enum deserialization has been changed, see also serde-rs/json#1324. Most likely has no effect for most use cases. -
[Build] Removed
strumdependency (thanks @mcbegamerxx954!) -
[Build] Removed
duplicatedependency