lincolns

Crates.iolincolns
lib.rslincolns
version0.1.1
sourcesrc
created_at2019-09-23 12:42:11.448309
updated_at2019-09-25 10:24:07.358331
descriptionA JSON Pointer index for line/column information within JSON and YAML content
homepagehttps://github.com/softprops/lincolns
repositoryhttps://github.com/softprops/lincolns
max_upload_size
id166959
size27,435
cargo (github:rustpq:cargo)

documentation

https://docs.rs/lincolns

README

👉 #️⃣

lincolns

A JSON Pointer index for line/column information within JSON and YAML content


📦 install

Add the following to your Cargo.toml file's [dependencies] heading

[dependencies]
lincolns = "0.1"

🤸 usage

Lincolns exposes two sets of operations: one to load YAML/JSON content into an index for lookup and one to perform the lookup

use lincolns::Position;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
  Ok(
    println!(
      "{:#?}",
      from_str("path/to/file.yml")?.get("/path/to/field")
    )
  )
}

If you care to see what JSON pointer paths are available you can iterate over them using iter

use lincolns::from_str;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
  for (ptr, pos) in from_str("path/to/file.yml")?.iter() {
    println!("{} => {:?}", ptr, pos);
  }
  Ok(())
}

That's it.

🤔 lincolns?

lin(e and )col(umn)n(umber)s

Doug Tangren (softprops) 2019

Commit count: 32

cargo fmt