4 releases

0.3.1 Dec 6, 2018
0.3.0 Nov 29, 2018
0.2.1 Nov 29, 2018
0.2.0 Nov 29, 2018

#140 in #json-parser

Download history 830/week @ 2024-01-03 686/week @ 2024-01-10 650/week @ 2024-01-17 302/week @ 2024-01-24 291/week @ 2024-01-31 579/week @ 2024-02-07 419/week @ 2024-02-14 642/week @ 2024-02-21 397/week @ 2024-02-28 82/week @ 2024-03-06 39/week @ 2024-03-13 171/week @ 2024-03-20 426/week @ 2024-03-27 514/week @ 2024-04-03 389/week @ 2024-04-10 342/week @ 2024-04-17

1,726 downloads per month

MIT license

12KB
316 lines

rjson : a minimal json parser for rust

  • Contain a single standalone lib.rs that do all the jobs.
  • Impl the traits with your own structs before parse.
  • A simple Impl can be, enum for Value, the same enum for Null, Vec for Array and BTreeMap for Object.
  • It requires only core and alloc, nothing else, including std.
  • In no_std environment, it need a global allocator to work.

Reminder

  • We allow , after the last item/member of Array/Object.
  • We treat unescaped line breaks as normal char, and ignore escaped line breaks.
  • We do not support surrogate unicode char.
  • We use f64 for all numbers, but you can use others. Remind: f64 means i52.
  • We take &[char], not &[u8], and not &str.
  • No stringify or encode, because they should not be a part of the traits.
  • Instead of returning None, we simply ignore chars after the data.
  • The position where data ends is returned through index. You can compare it with len() - 1.
  • This value is also useful when Option::None returned, by indicating where the syntax error occurs.
  • parse may return all possible values, not only Array and Object.

No runtime deps