bourne

Crates.iobourne
lib.rsbourne
version0.2.1
created_at2024-12-20 13:05:05.792798+00
updated_at2025-04-20 04:43:36.716776+00
descriptionA simple JSON library.
homepage
repositoryhttps://github.com/ErisianArchitect/bourne
max_upload_size
id1490157
size43,361
Null (ErisianArchitect)

documentation

README

giphy

A simple JSON library written entirely in Rust.

Use preserve_order feature to preserve element order in Value::Object(_). This will use indexmap, which will incur a significant memory overhead.

use std::str::FromStr;

use bourne::{
    Value,
    json
};
use bourne::format::Indent;
use bourne::error::ParseError;

fn main() -> Result<(), ParseError> {
    let number = 3.14;
    let value = json!(
        {
            "example" : "Hello, world!",
            "number" : number,
        }
    );
    println!("{value}");
    println!("################################");
    let value = Value::from_str(r#"
        {
            "integer" : 123,
            "decimal" : [3.14, 1.0],
            "keywords" : [true, false, null],
            "nested" : {
                "one" : 1,
                "two" : {
                    "three" : 3
                }
            }
        }
    "#)?;
    println!("{}", value.pretty_print());
    println!("################################");
    println!("{}", value.pretty_print_format(Indent::Tabs(1), true));
    Ok(())
}
Commit count: 89

cargo fmt