6 releases

0.1.5 Apr 24, 2024
0.1.4 Apr 24, 2024

#812 in Parser implementations

Download history 23/week @ 2024-07-01 28/week @ 2024-07-29 42/week @ 2024-08-19 29/week @ 2024-08-26 23/week @ 2024-09-02 40/week @ 2024-09-09 22/week @ 2024-09-16 125/week @ 2024-09-23 45/week @ 2024-09-30 37/week @ 2024-10-07

229 downloads per month

MIT/Apache

94KB
2.5K SLoC

Zero JSON (zjson)

Parse JSON with zero allocation.

Status

This library is still in development. We still need:

  • Tests
  • Better documentation
  • More examples
  • Potentially a simplified API (it is not stable yet)

If you would like to contribute to this, please open an issue or contact me directly.

How to Use

Create a document from a JSON string.

Call next on any container (document, object, array) to get the next value. The returned value must be fully parsed before continuing.

Match on the returned Any value to handle each type.

Call get on a single value (string, number, boolean, null) to get it.

Call finish on a value to skip it (so that the parent container can continue).

Features

  • alloc - adds features that require allocation (only allocating escaped strings, there is a no-alloc alternative)
  • std (enables alloc, default) - adds features that require std (Error impls)

Specification

The parser is (hopefully) ECMA 404 complient, including support for Unicode surrogate pairs. The diagram on json.org is a great representation of the standard.

Alternatives

This library is designed to be fast and require no allocations. This means that the API is more complex than something like serde with serde_json.

Examples

There are examples in the examples directory.

License

Zero JSON is licensed under either the MIT license or the Apache License Version 2.0 at your option.

No runtime deps

Features