Expand description
§use-json
Practical JSON utility primitives for lightweight inspection, detection, quoting, and formatting.
Warning: versions below
0.3.0are experimental and may change as the crate matures.
§Example Usage
use use_json::{JsonKind, compact_json_basic, detect_json_kind, quote_json_string};
let compact = compact_json_basic("{ \"ok\": true, \"name\": \"RustUse\" }");
let quoted = quote_json_string("line\nbreak");
assert_eq!(compact, "{\"ok\":true,\"name\":\"RustUse\"}");
assert_eq!(quoted, "\"line\\nbreak\"");
assert_eq!(detect_json_kind("[1, 2, 3]"), JsonKind::Array);§Scope
- small JSON shape and primitive detection helpers
- conservative quoting and escaping helpers for strings
- whitespace compaction that preserves content inside JSON strings
§Non-Goals
- a full JSON parser
- JSONPath support
- schema validation
- a replacement for
serde_json
§License
Licensed under either of the following, at your option:
- MIT License
- Apache License, Version 2.0
Enums§
- Json
Kind - A conservative classification of JSON input.
Functions§
- compact_
json_ basic - Removes whitespace outside strings without attempting full JSON parsing.
- detect_
json_ kind - Detects the conservative JSON kind represented by the input.
- escape_
json_ string - Escapes a Rust string for JSON string content.
- is_
json_ bool - Returns
truewhen the input is a JSON boolean literal. - is_
json_ null - Returns
truewhen the input is thenullliteral. - is_
json_ number - Returns
truewhen the input is a valid JSON number literal. - is_
json_ string - Returns
truewhen the input is a quoted JSON string. - looks_
like_ json - Returns
truewhen the input looks like a supported JSON value. - looks_
like_ json_ array - Returns
truewhen the input looks like a JSON array. - looks_
like_ json_ object - Returns
truewhen the input looks like a JSON object. - quote_
json_ string - Quotes a Rust string as a JSON string literal.
- unquote_
json_ string - Unquotes a conservative JSON string literal.