Crate partial_json_fixer

Source
Expand description

Partial JSON fixer

This is a zero dependency partial json fixer. It is very lenient, and will accept some erroneous JSON too. For example, {key: “value”} would be valid.

This can be used to parse partial json coming from a stream.

Structs§

JsonArray
JsonObject
JsonToken
Span

Enums§

JsonError
JsonTokenKind
JsonUnit
JsonValue

Functions§

fix_json
Takes a partial JSON string, kinda parses it and returns a complete JSON string. This function keeps the JSON as a string, goes through it and analyzes the brackets, strings, etc, to determine the missing stuff, and adds it. This approach is likely faster than the parsing appraoch (TODO: benchmmark maybe) It’s assumed that the given JSON would always be a valid incomplete JSON.
fix_json_parse
Takes a partial JSON string, kinda parses it and returns a complete JSON object The JSON is tokenized and parsed. It can then be converted to a string with .to_string() method