not-fl3 / nanoserde

Serialisation library with zero dependencies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DeJson doesn't handle all possible character escapes allowed in JSON

thomcc opened this issue · comments

https://github.com/not-fl3/nanoserde/blob/master/src/serde_json.rs#L513-L520 is missing \b, \f, \u hex hex hex hex (note that unfortunately you need to decode two of these to handle paired surrogates properly, e.g. "\ud83d\ude40" is equivalent to "🙀")...

commented

yeah I'm running into issues with this
{"fact":"Some cats have survived falls of over 65 feet (20 meters), due largely to their \u201crighting reflex.\u201d The eyes and balance organs in the inner ear tell it where it is in space so the cat can land on its feet. Even cats without a tail have this ability.","length":249}

commented

the unescape crate can be used on the input text as a temporary workaround.

The unescape crate fails on the example I gave, it doesn't handle paired surrogates which are legal in JSON (and not rare for some JVM json serializers).

commented

oh, it worked on my own use case, whoops (which was just simple encoded literals like ')