pub struct Json;Expand description
Parser for the json format: standard JSON into a source-located value tree.
Objects, arrays, and scalars map to the value tree with a per-node span Location; JSON
null becomes Value::Null. Stateless — construct with Json::new.
use tanzim_parse::{Parse, json::Json};
use tanzim_source::SourceBuilder;
let source = SourceBuilder::new()
.with_source("file")
.with_resource("config.json")
.build()
.unwrap();
let value = Json::new().parse(&source, br#"{"port":8080}"#).unwrap();
let port = value.value().as_map().unwrap().get("port").unwrap();
assert_eq!(port.value().as_int().unwrap(), 8080);Implementations§
Trait Implementations§
impl Copy for Json
Auto Trait Implementations§
impl Freeze for Json
impl RefUnwindSafe for Json
impl Send for Json
impl Sync for Json
impl Unpin for Json
impl UnsafeUnpin for Json
impl UnwindSafe for Json
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more