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
504 downloads per month
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
forValue
, the sameenum
forNull
,Vec
forArray
andBTreeMap
forObject
. - It requires only
core
andalloc
, nothing else, includingstd
. - 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
meansi52
. - We take
&[char]
, not&[u8]
, and not&str
. - No
stringify
orencode
, 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 withlen() - 1
. - This value is also useful when
Option::None
returned, by indicating where the syntax error occurs. parse
may return all possible values, not onlyArray
andObject
.