Expand description
This crate offers a replacement for serde-json’s Value type, which is
significantly more memory efficient.
As a ballpark figure, it will typically use half as much memory as
serde-json when deserializing a value and the memory footprint of cloning
a value is more than 7x smaller.
The primary type exposed by this crate is the IValue type. It is guaranteed
to be pointer-sized and has a niche (so Option<IValue> is also guaranteed
to be pointer-sized).
Cargo features:
-
arbitrary_precisionStore JSON numbers as their exact decimal value rather than rounding tof64. A short decimal is packed inline; a larger or more precise one spills to a heap arbitrary-precision decimal. With this on,"0.1"is the exact tenth — a different number from thef640.1— and a magnitude beyondf64’s range is representable. It also switches deserialization to preserve the exact literal (via serde_json’s ownarbitrary_precision). Off by default; without it every number is exactly anf64. -
ctorA global string cache is used when interning strings. This cache is normally initialized lazily on first use. Enabling thectorfeature will cause it to be eagerly initialized on startup. There is no performance benefit to this, but it can help avoid false positives from tools likemockallocwhich try to detect memory leaks during tests. -
indexmapAdds conversions betweenIObjectandindexmap’sIndexMap. -
broken-borrow-impl-compatAddsBorrow<str>forIString, for libraries that require it. Unsound to rely on for hash-map keys (see the impl’s own note); enable only as a temporary measure. -
tracingForwards tomockalloc’stracingfeature, for allocation tracing under tests.
Re-exports§
pub use array::IArray;pub use number::INumber;pub use number::ParseNumberError;pub use object::IObject;pub use string::IString;
Modules§
- array
- Functionality relating to the JSON array type.
- number
- Functionality relating to the JSON number type.
- object
- Functionality relating to the JSON object type.
- string
- Functionality relating to the JSON string type.
Macros§
Structs§
Enums§
- Destructured
- Enum returned by
IValue::destructureto allow matching on the type of an ownedIValue. - Destructured
Mut - Enum returned by
IValue::destructure_mutto allow matching on the type of a mutable reference to anIValue. - Destructured
Ref - Enum returned by
IValue::destructure_refto allow matching on the type of a reference to anIValue. - Value
Type - Enum which distinguishes the six JSON types.
Traits§
- Value
Index - Trait which abstracts over the various number and string types
which can be used to index into an
IValue.
Functions§
- from_
value - Converts an
IValueto an arbitrary type using that type’sserde::Deserializeimplementation. - to_
value - Converts an arbitrary type to an
IValueusing that type’sserde::Serializeimplementation.