- Contain a single standalone
lib.rsthat do all the jobs. - Impl the traits with your own structs before
parse. - A simple Impl can be,
enumforValue, the sameenumforNull,VecforArrayandBTreeMapforObject. - It requires only
coreandalloc, nothing else, includingstd. - In
no_stdenvironment, 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
f64for all numbers, but you can use others. Remind:f64meansi52. - We take
&[char], not&[u8], and not&str. - No
stringifyorencode, 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::Nonereturned, by indicating where the syntax error occurs. parsemay return all possible values, not onlyArrayandObject.