#source-map #json #parser #generate

json-sourcemap

A library for parsing and generating JSON sourcemaps

3 releases

0.1.2 May 5, 2023
0.1.1 Mar 11, 2023
0.1.0 Mar 11, 2023

#1576 in Parser implementations

46 downloads per month

MIT/Apache

22KB
626 lines

json-sourcemap.rs

Just a json-source-map's port to Rust.

Usage

Add this to your Cargo.toml:

[dependencies]
json-sourcemap = "0.1"

Example

use json_sourcemap::Options;

fn main() {
    let json = r#"{
        "foo": "bar",
        "baz": 42
    }"#;

    let options = Options::default();
    let map = json_sourcemap::parse(json, options).unwrap();

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

    println!("{:?}", map.get_location("/foo").unwrap());

    let locs = map.get_location("/baz").unwrap();
    println!("{:?}", locs.key())
}

Dependencies

~0.7–1.5MB
~34K SLoC