json-rust icon indicating copy to clipboard operation
json-rust copied to clipboard

Allow extra characters at end

Open Timmmm opened this issue 5 years ago • 1 comments

It would be really helpful for my use case if there were a way to allow data after the JSON, and to report how much JSON was actually read.

For example if I have data like this:

{"type": "string", "length": 5}Hello

It would return the JSON data, plus a length of 31 (up to the }).

Looks like this would be easy something along the lines of this commit which I have not tested (or even compiled).

Bit of a weird use case!

Timmmm avatar Mar 13 '20 09:03 Timmmm

By default, and per spec, any extra characters at the end are to be considered errors, however I think I can add that as an option with a generic on the parser.

This could also make it possible to have an iterator parser, eg. for log formats that print json objects on new lines.

maciejhirsz avatar Mar 14 '20 09:03 maciejhirsz