chadaustin / sajson

Lightweight, extremely high-performance JSON parser for C++11
MIT License
562 stars 42 forks source link

Stream json parsing #44

Closed vmalyasov closed 6 years ago

vmalyasov commented 6 years ago

Is there a way to parse the JSON string from a network stream (JSON as bytes stream or data chunks)?

chadaustin commented 6 years ago

There isn't, no. sajson relies on having the entire input document available. (Fortunately, sajson parses at a rate of hundreds of MB per second, so streaming should not be necessary except in the most extreme cases.)

Curious: what use case are you imagining?

vmalyasov commented 6 years ago

We make several async http requests from the server and every request contains the huge JSON, and to avoid extra memory allocation (in my case for a mobile app) we should use stream parsing

chadaustin commented 6 years ago

Ah, yeah. If keeping the entire JSON document in memory is not desirable, sajson is not a good fit. :/ I would look for a streaming parser.

Cheers!