Crate json2toon_rs

Crate json2toon_rs 

Source
Expand description

§json2toon_rs

A fast, bidirectional JSON ⟷ TOON converter based on the TOON v2.0 specification.

TOON (Token-Oriented Object Notation) is a line-oriented, indentation-based format that efficiently represents JSON data with minimal quoting and explicit structure.

This crate provides both encoding (JSON → TOON) and decoding (TOON → JSON) with full spec compliance, automatic format detection, and configurable options.

§Example

use json2toon_rs::{encode, decode, EncoderOptions, DecoderOptions, DecodeError};
use serde_json::json;

// Encode JSON to TOON
let data = json!({
    "name": "Alice",
    "age": 30,
    "tags": ["admin", "user"]
});

let toon = encode(&data, &EncoderOptions::default());
println!("{}", toon);

// Decode TOON back to JSON
let decoded = decode(&toon, &DecoderOptions::default()).unwrap();
assert_eq!(data, decoded);

Structs§

DecoderOptions
Decoder configuration options
EncoderOptions
Encoder configuration options

Enums§

DecodeError
An error that can occur during the decoding of a TOON string.
Delimiter
Delimiter type for separating array values and tabular rows

Functions§

decode
Decode TOON format to JSON value
encode
Encode a JSON value to TOON format