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

#213 in #json-parser

Download history 81/week @ 2024-07-20 112/week @ 2024-07-27 25/week @ 2024-08-03 2/week @ 2024-08-10 9/week @ 2024-08-17 7/week @ 2024-08-24 126/week @ 2024-08-31 169/week @ 2024-09-07 93/week @ 2024-09-14 293/week @ 2024-09-21 144/week @ 2024-09-28 49/week @ 2024-10-05 4/week @ 2024-10-12 259/week @ 2024-10-19 82/week @ 2024-10-26 158/week @ 2024-11-02

504 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