Expand description
Strict, bounded, and deterministic JSON for reliability-sensitive Rust.
reliakit-json is built for systems that process untrusted JSON or need
predictable output: it parses a strict subset of RFC 8259, rejects
duplicate object keys, enforces explicit resource limits,
preserves number precision, reports errors with location and path, and
serializes deterministically. It has no external dependencies, forbids
unsafe code, and supports no_std (with alloc).
It deliberately does not provide derive macros, schema validation, JSON5, comments, trailing commas, lenient parsing, or SIMD throughput.
§Example
use reliakit_json::{parse_str, to_compact_string};
let value = parse_str(r#"{"name":"reliakit","ok":true}"#).unwrap();
assert_eq!(value.as_object().unwrap().get("name").unwrap().as_str(), Some("reliakit"));
// Serialization is deterministic and preserves member order.
assert_eq!(to_compact_string(&value), r#"{"name":"reliakit","ok":true}"#);
// Strict by default: duplicate keys are rejected, not silently resolved.
assert!(parse_str(r#"{"a":1,"a":2}"#).is_err());§Limits
parse applies conservative JsonLimits by default. Use
parse_with_limits to choose a profile or tune individual limits:
use reliakit_json::{parse_with_limits, JsonLimits};
let limits = JsonLimits::conservative().with_max_depth(8);
assert!(parse_with_limits(b"[[[[[[[[[[1]]]]]]]]]]", limits).is_err());Structs§
- Json
Error - An error produced while parsing or serializing JSON.
- Json
Limits - Resource limits enforced while parsing.
- Json
Member - A single object member (key/value pair).
- Json
Number - A JSON number that preserves its exact, validated source representation.
- Json
Object - A JSON object: members in insertion order with unique keys.
- Json
Path - The location of an error within the JSON document, as a path of object keys
and array indices from the document root (
$).
Enums§
- Json
Error Kind - The category of a parse or serialization failure.
- Json
Limit Kind - A resource limit that was exceeded while parsing.
- Json
Number Error - An error from a
JsonNumberconversion. - Json
Path Segment - One segment of a
JsonPath. - Json
Value - An owned JSON value.
Functions§
- parse
- Parses a JSON value from UTF-8 bytes using the default
JsonLimits. - parse_
str - Parses a JSON value from a
&strusing the defaultJsonLimits. - parse_
with_ limits - Parses a JSON value from UTF-8 bytes with explicit
JsonLimits. - to_
canonical_ string - Serializes a value to its RFC 8785 (JCS) canonical form as a
String. - to_
canonical_ vec - Serializes a value to its RFC 8785 (JCS) canonical form as UTF-8 bytes.
- to_
compact_ string - Serializes a value to a compact JSON string (no insignificant whitespace).
- to_
compact_ vec - Serializes a value to compact JSON bytes. See
to_compact_string.