| Crates.io | include_json |
| lib.rs | include_json |
| version | 0.1.1 |
| created_at | 2025-02-02 02:13:25.148698+00 |
| updated_at | 2025-03-03 23:31:03.238091+00 |
| description | Parse JSON file at compile time and embed as serde_json::Value |
| homepage | |
| repository | https://github.com/dtolnay/include-json |
| max_upload_size | |
| id | 1539188 |
| size | 34,508 |
include_json!Rust macro to parse a JSON file at compile time and compile it into the program
as a serde_json::Value.
Example — supplying a JSON file as context inside a MiniJinja template:
use include_json::include_json;
fn main() {
let pkg = include_json!(concat!(env!("CARGO_MANIFEST_DIR"), "/package.json"));
let mut env = minijinja::Environment::new();
env.add_template("example", include_str!("example.jinja")).unwrap();
let tmpl = env.get_template("example").unwrap();
println!("{}", tmpl.render(minijinja::context!(pkg)).unwrap());
}