Skip to main content

Crate tjson

Crate tjson 

Source
Expand description

A Rust library and CLI tool for TJSON — a readable, round-trip-safe alternative syntax for JSON.

§Quick start

// Deserialize TJSON directly into any serde type
#[derive(serde::Serialize, serde::Deserialize, PartialEq, Debug)]
struct Person { name: String, age: u32 }

let p: Person = tjson::from_str("  name: Alice  age:30").unwrap();

// Serialize any serde type to TJSON
let s = tjson::to_string(&p).unwrap();

§Features

  • serde_json (default) — enables From<serde_json::Value> for Value and From<Value> for serde_json::Value. Disable if you don’t use serde_json directly and want to avoid pulling its arbitrary_precision feature into your build.

Structs§

Entry
A single key-value entry in a TJSON object.
InvalidNumber
Error returned when a value is not a finite, valid JSON number.
Number
A JSON number value, stored as its original string representation.
ParseError
A parse error with source location and optional source line context.
RenderOptions
Options controlling how TJSON is rendered. Use RenderOptions::default for sensible defaults, or RenderOptions::canonical for a compact, diff-friendly format. All fields are set via builder methods.

Enums§

BareStyle
Controls whether bare (unquoted) strings and keys are preferred.
Error
The error type for all TJSON operations.
FoldStyle
Controls how long strings are folded across lines using / continuation markers.
IndentGlyphMarkerStyle
Controls how the /< opening glyph of an indent-offset block is placed.
IndentGlyphStyle
Controls when /< / /> indent-offset glyphs are emitted to push content to visual indent 0.
MultilineStyle
Controls which multiline string format is preferred when rendering strings with newlines.
StringArrayStyle
Controls how arrays of short strings are packed onto a single line.
TableUnindentStyle
Controls how tables are horizontally repositioned using /< /> indent-offset glyphs.
Value
A parsed TJSON value. Mirrors the JSON type system with the same six variants.

Constants§

DEFAULT_WRAP_WIDTH
MIN_WRAP_WIDTH

Functions§

from_str
Parse a TJSON string and deserialize it into T using serde.
to_string
Serialize value to a TJSON string using default options.
to_string_with
Serialize value to a TJSON string using the given options.

Type Aliases§

Result
Convenience Result type with Error as the default error type.