json

Macro json 

Source
json!() { /* proc-macro */ }
Expand description

Convert JSON-like Rust tokens into a &'static str at compile time.

Accepts a superset of JSON syntax using Rust token trees:

  • Objects: { "key": value, ... }
  • Arrays: [value, ...]
  • Strings: "hello"
  • Numbers: 42, 3.14, -1
  • Booleans: true, false
  • Null: null
  • Trailing commas are stripped
const CFG: &str = ktstr::json!({
    "layers": [{
        "name": "batch",
        "kind": { "Grouped": { "cpus_range": [0, 4] } },
    }],
});