static-json-pointer
Macro to extract Rust tokens and literals from a JSON schema
If you have a file schema.json
:
You can use a JSON pointer to specify the field for extracting a token or literal from JSON at compile time:
extern crate static_json_pointer;
use json_token;
// let name = String::from("Zazu");
let name = json_token! from;
// let age = Option<u32>::from(42);
let age = json_token! from;
assert_eq!;
assert_eq!;
The deserialized JSON is cached during build to prevent redundant reading and parsing during build.