netplex / json-smart-v2

Apache License 2.0
149 stars 68 forks source link

Parsing partial and incomplete JSON without error #177

Open SuperPat45 opened 7 months ago

SuperPat45 commented 7 months ago

Playing with the OpenAI’s streaming APIs, the response stream return partial JSON data I need to exploit immediately for smooth experience.

This may be achieved by adding a new clean data functions like: String data = JSONValue.cleanData(String) Who can append missing close token like: 1 1w9UgbLMDwvHROu7NLUa2g

Alternatively, this can also be done by adding new parser functions that ignore EOF errors. JSONValue.parsePartial(...); or with a new class: JSONPartialValue.parse(...);

With this, I'll be able to show, to my user, a tree that fills up as data comes in.

UrielCh commented 6 months ago

Nice! It's not too complicated to implement. If I can pay for it, I'm willing to implement it.