const_json 0.1.0

Provides a way to embed and access const JSON in Rust code
Documentation
  • Coverage
  • 94.44%
    17 out of 18 items documented1 out of 9 items with examples
  • Size
  • Source code size: 9.35 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.24 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • mysteriouslyseeing/const_json
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mysteriouslyseeing

const_json

Provides a way to embed and access const JSON in Rust code, using a single macro_rules declaration, and no dependencies, so it is quick to compile.

use const_json::{Json, const_json};

const JSON: Json = const_json!({
    "null": null,
    "bool": true,
    "float": 12.3,
    "int": 42,
    "str": "Hello, World!",
    "array": [1, null],
    "object": {
        "inner_bool": false,
        "inner_str": "foo bar"
    },

    "variable": VARIABLE,
    // Has to be surrounded in parentheses if it is a complex expression
    "function_result": (10 + 4)
});

const VARIABLE: i64 = 10;