Expand description
babbel_json - A lightweight, modular JSON toolkit for Rust
This library provides a flexible JSON implementation with:
- Core Node type for representing JSON structures
- Parser to build Node trees from streams
- Multiple format serializers (JSON, YAML, XML, Bencode)
- File and buffer I/O abstractions (with
file-iofeature) - Pretty-printing utilities
- Unicode-aware file handling (with
file-iofeature)
§no_std Support
This library supports no_std environments with the alloc crate.
Disable default features and enable only what you need:
[dependencies]
babbel_json = { version = "0.1", default-features = false, features = ["alloc"] }Minimum supported Rust version: 1.88.0
Re-exports§
pub use error::JsonError;pub use error::parse_error::ParseError;pub use stringify::pretty::stringify_pretty;pub use misc::get_version as version;pub use misc::print;pub use misc::strip as strip_whitespace;pub use parser::pull_parser::JsonPullEvent;pub use parser::pull_parser::JsonPullParser;pub use parser::pull_parser::JsonScalar;pub use nodes::node::Node;pub use parser::config::ParserConfig;pub use parser::default::from_bytes;pub use parser::default::from_str;pub use parser::default::parse;pub use parser::default::parse_with_config;pub use parser::stats::ParseStats;pub use parser::validate::validate_json;pub use parser::arena;pub use parser::fast;pub use parser::sso;pub use stringify::optimized::stringify_optimized;pub use stringify::bencode::stringify as to_bencode;pub use stringify::default::stringify;pub use stringify::toml::stringify as to_toml;pub use stringify::xml::stringify as to_xml;pub use stringify::yaml::stringify as to_yaml;pub use nodes::json_pointer::get as pointer_get;pub use nodes::json_pointer::get_mut as pointer_get_mut;pub use nodes::json_pointer::remove as pointer_remove;pub use nodes::json_pointer::set as pointer_set;pub use nodes::schema;pub use nodes::patch;pub use parser::json5;pub use parser::json5::parse_json5;pub use lines::JsonLinesConfig;pub use lines::JsonLinesReader;pub use lines::parse_json_lines;pub use lines::to_json_lines;pub use lines::to_json_lines_stream;pub use engine::Json5Engine;pub use engine::JsonEngine;pub use engine::JsonLinesEngine;
Modules§
- embedded
- Embedded systems utilities and helpers Embedded utilities module providing common patterns and helpers for embedded systems
- engine
- Format engine implementation adhering to OCP and DIP JSON and JSON5 Format Engines adhering to OCP and DIP.
- error
- Module defining error types and handling for JSON operations.
- file
- Module handling JSON file reading and writing operations
- io
- Module providing input/output operations for reading and writing JSON data
- lines
- Line-delimited JSON (JSON Lines / NDJSON) streaming reader and writer Line-delimited JSON (JSON Lines / NDJSON / JSONL) streaming parser and emitter.
- macros
- Macros for convenient JSON construction Macros for convenient JSON construction
- misc
- Module containing utility functions and helpers for JSON processing Miscellaneous utility functions for JSON processing Contain functionality for version information and formatted JSON printing
- nodes
- Module containing JSON data structure definitions and node types
- parser
- Module implementing JSON parsing and value extraction Parser module for processing JSON data Implements parsing of JSON text into internal data structures Supports standard JSON types and syntax validation
- stringify
- Module for converting JSON structures to formatted strings
Macros§
- json
- Constructs a JSON value from a literal syntax
Structs§
- Array
VecDestination - Zero-allocation stack-based destination implementations Stack-allocated fixed-capacity byte buffer destination using const generics.
- Buffer
Destination - Destination implementation for writing JSON data to a memory buffer
In-memory byte buffer destination (
Vec<u8>). - Buffer
Source - Source implementation for reading JSON data from a memory buffer In-memory byte vector input source supporting both binary byte streaming and Unicode UTF-8 character streaming.
- File
Destination - Destination implementation for writing JSON data to a file File output destination writing to a buffered file on disk (32KB write buffer).
- File
Source - Source implementation for reading JSON data from a file File input source reading binary or text data from disk.
- Slice
Destination - Zero-allocation stack-based destination implementations Zero-allocation in-memory destination writing directly into a caller-supplied byte slice.
Enums§
- Format
- This enum represents different Unicode text file formats with their corresponding byte order marks (BOM) Represents different Unicode text file formats with their corresponding byte order marks (BOM).
- Numeric
- Core data structure representing a numeric value node in the parsed tree Represents different numeric types that can be stored in a JSON node Represents different numeric types that can be stored in AST nodes across format representations.
Functions§
- detect_
format - This function detects the Unicode format of a text file by examining its byte order mark (BOM) Detects the Unicode format of a text file by examining its byte order mark (BOM).
- from_
slice - Convenience function to parse JSON from a byte slice
- read_
file_ to_ string - This function reads a text file and returns its content as a String, handling different Unicode formats Reads a text file and returns its content as a normalized UTF-8 String, stripping BOM if present.
- to_
destination - Serialize a JSON
Nodedirectly to an [IDestination]. - to_
string - Serialize a JSON
Nodeinto an ownedString. - to_
string_ pretty - Serialize a JSON
Nodeinto a pretty-printedStringwith 2-space indentation. - to_vec
- Serialize a JSON
Nodeinto a byte vector (Vec<u8>). - write_
file_ from_ string - This function writes a string to a file in the specified Unicode format Writes a string to a file in the specified Unicode format, prepending the corresponding BOM.