- 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.
- 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
.