inline-json5_macro 0.1.0

Supporting crate for inline-json5. (Loess demo project.)
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 23.41 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 87.25 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Tamschi

inline-json5

This is a small crate to write JsonValues in Rust using JSON5 syntax.

So far it doesn't support interpolation, but has great error highlighting. (The macro recovers at each , or closing delimiter and can report further errors afterwards.)

// Example taken from <https://json5.org/>, modified.
let _ = json5!({
    // comments
    unquoted: "and you can quote me on that",
    singleQuotes: "I can use \"double quotes\" here",
    lineBreaks: "Look, Mom! \
No \\n's!",
    hexadecimal: 0xdecaf,
    leadingDecimalPoint: .8675309, andTrailing: 8675309.,
    positiveSign: +1,
    nan: NaN,
    infinity: infinity,
    negative_infinity: -infinity,
    trailingComma: "in objects", andIn: ["arrays",],
    "backwardsCompatible": "with JSON",
});

The macro is fully hygienic even though it is proc macro backed, and it compiles still quite quickly since Loess is a lightweight macro framework.