serde_wat

Crates.ioserde_wat
lib.rsserde_wat
version0.1.0
sourcesrc
created_at2016-08-24 01:30:03.514022
updated_at2016-08-24 01:30:03.514022
descriptionScary macros for serde_json
homepage
repositoryhttps://github.com/mgoszcz2/serde_wat
max_upload_size
id6089
size6,213
Maciej Goszczycki (maciej-irl)

documentation

http://mgoszcz2.github.io/serde_wat/serde_wat/index.html

README

Scary macros for serde_json

Wat

Documentation

Macros for easily accessing serde_json Values in JavaScript like fashion

#[macro_use] extern crate serde_wat;
extern crate serde_json;

use serde_json::from_str;
use serde_json::value::Value;

let a: Value = from_str(r#"{"b": {"c": 42}}"#).unwrap();
// Access unwrapping
assert_eq!(wat!(a.b.c as i64), 42);
// Safe access
assert_eq!(wat!(a.b as &str?), None);
// Testing
assert_eq!(wat!(a is bool), false);

Examples

wat!(a.b.c as i64);
wat!(a as &mut Vec?);
wat!(a as &str);
wat!(a.b is i64);
wat!(a.b is &Map?);
wat!(a is &Map);
wat!(a.0 as bool);
Commit count: 8

cargo fmt