Expand description
§json-colorizer
A fast, lightweight JSON formatter, pretty-printer, colorizer, and query library for Rust.
Use it to pretty-print JSON with syntax highlighting in the terminal, compact-print JSON, or query nested values with dot-path notation.
§Quick Start
use json_colorizer::{format_json, format_json_compact, query, FormatOptions};
use serde_json::json;
let value = json!({"name": "Alice", "scores": [95, 87, 100]});
// Pretty-print with colors
let output = format_json(&value, &FormatOptions::default());
println!("{}", output);
// Compact output
let compact = format_json_compact(&value);
println!("{}", compact);
// Query a nested value
let score = query(&value, ".scores[0]").unwrap();
assert_eq!(score, &json!(95));Structs§
- Format
Options - Options for controlling JSON output formatting.
Enums§
- Query
Error - Error returned when a query path is invalid or does not match the JSON.
Functions§
- format_
json - Format a JSON value as a pretty-printed string.
- format_
json_ compact - Format a JSON value as a compact (single-line, no whitespace) string.
- parse_
and_ format - Parse a raw JSON string and return the formatted (colorized) output.
- query
- Query a nested value inside
rootusing a dot-path string.