2 releases

0.1.2 Mar 25, 2021
0.1.1 Mar 25, 2021
0.1.0 Mar 21, 2021

#2479 in Parser implementations

Download history 5/week @ 2024-07-22 13/week @ 2024-07-29 2/week @ 2024-08-05 14/week @ 2024-08-12 6/week @ 2024-08-19 33/week @ 2024-08-26 8/week @ 2024-09-02 9/week @ 2024-09-09 8/week @ 2024-09-16 45/week @ 2024-09-23 16/week @ 2024-09-30 6/week @ 2024-10-07 33/week @ 2024-10-14 145/week @ 2024-10-21 26/week @ 2024-10-28 20/week @ 2024-11-04

225 downloads per month

Custom license

20KB
379 lines

sn

sn is a minimalistic and simple Rust JSON parser.
sn operates by borrowing slices of the input string, meaning no data is copied during the parsing process, which helps improve efficiency.

WIP

This library is still in a very early working state and is subject to change a lot as it matures. Use At Your Own Risk.

Examples

Loading a JSON file from the filesystem and parsing it into a Value:

use sn::Parser;
use std::fs::read_to_string;

fn main() {
    let raw_json = read_to_string("./my_json.json").unwrap();
    let mut parser = Parser::new(raw_json.as_bytes());
    let parsed_json = parser.parse();

    println!("{:?}", parsed_json);
}

Usage

Add sn to your Cargo.toml:

[dependencies]
sn = "0.1.1"

lib.rs:

sn

sn is a minimalistic and simple Rust JSON parser.
sn operates by borrowing slices of the input string, meaning no data is copied during the parsing process, which helps improve efficiency.

WIP

This library is still in a very early working state and is subject to change a lot as it matures. Use At Your Own Risk.

Bytes

Bytes is a struct used internally to represent string slices, encoded as &[u8]. The primary use case for this struct is the Debug implementation, which converts the contents to a string.

Examples

Loading a JSON file from the filesystem and parsing it into a Value:

use sn::Parser;

let raw_json = r#"{ "a": [1, 2, 3], "b": null }"#;
let mut parser = Parser::new(raw_json.as_bytes());
let parsed_json = parser.parse();

println!("{:?}", parsed_json);

Usage

Add sn to your Cargo.toml:

[dependencies]
sn = "0.1.2"

No runtime deps