Skip to main content

Crate tson

Crate tson 

Source
Expand description

§TSON - Terse JSON Binary Format

A compact binary format for JSON data, designed for microcontrollers and constrained environments.

§Feature flags

  • std (default on) - enables std::io-based helpers and the IoError variant in TsonError. When disabled, the library is no_std and only requires the alloc crate.
  • json (default on) - enables JSON ↔ TSON compilation via serde_json.

§Quick start

let json = r#"{"name":"Alice","age":30}"#;
let doc = tson::compile_json(json).unwrap();
let bytes = tson::to_bytes(&doc).unwrap();
let restored = tson::from_bytes(&bytes).unwrap();
let value = tson::decompile_to_value(&restored).unwrap();
assert_eq!(value.to_string(), r#"{"age":30,"name":"Alice"}"#);

Re-exports§

pub use stream::TsonStreamReader;
pub use tson::decode_definitions;
pub use tson::emit_value;
pub use tson::from_bytes;
pub use tson::to_bytes;
pub use tson::TsonChunk;
pub use tson::TsonData;
pub use tson::TsonDefinition;
pub use tson::TsonDocument;
pub use tson::TsonHeader;
pub use tson::TsonType;
pub use tson::emit;
pub use tson::emit_with_context;
pub use tson::compile_json;
pub use tson::compile_json_file;
pub use tson::compile_value;
pub use tson::decompile_to_value;
pub use tson::decompile_tson_file;

Modules§

compile
decode
decompile
encode
error
prelude
Shared prelude for no_std / std compatibility.
stream
structure
tson