Streaming JSON library ‘Struson’ version 0.8.0 released

2026-11-13来源 Rust Users ForumEnglish

I have just released version 0.8.0 of my streaming JSON library 'Struson'. Struson streams JSON data using Read and Write without having to hold the complete data in memory, and provides API which directly corresponds to the JSON data types, allowing you to read and write arbitrary JSON data.

The highlights this release, which are possibly interesting for new users as well, are:

  • 'recoverable' deserialization

    Struson's serde integration was extended with new API JsonReader::deserialize_next_recoverable and SimpleJsonReader::read_deserialize_recoverable which attempts to deserialize a value whose JSON structure or type might be unexpected. In this case the reader can be 'recovered' and deserialization can continue with the next value.
    Unlike other implementations such as serde_with's DefaultOnError the full value does not have to be buffered temporarily in memory, and the user can inspect the original error and then decide whether to attempt recovery or to abort reading.

  • detection of duplicate member names during reading

    Allows detecting and rejecting duplicate member names such as {"a": 1, "a": 2} when reading a JSON object. Disabled by default but can be enabled using ReaderSettings::duplicate_name_detection.

  • custom formatting when writing JSON numbers

    The new NumberFormatter trait allows you customize how JSON numbers are formatted, for example to increase performance by using third-party libraries such as zmij, or to use scientific notation for floating point numbers.

(full changelog)

Hopefully the documentation and the examples provide enough information to understand the API and to get started, but if you have any questions or suggestions feel free to post them here. Any feedback is appreciated!

1 post - 1 participant

Read full topic

原文:https://www.a8q9.cn/en/article/streaming-json-library-struson-version-0-8-0-released-72dca0.html

相关文章