How to parse JSON being downloaded as a stream on Swift? The stream gives incomplete JSON data each time. This is because I have to download MBs of data, the main component of which is a long array of objects, and I do not want the user to wait till I get the complete data. Is it possible to keep parsing the JSON data sequentially while streaming? Basically, something like what Jackson allows on Android, or a YAJLiOS Parser implementation for Swift
Stream based JSON parsing on Swift
Basically, what you require is a SAX parser. NSJSONSerialization is a DOM parser. One such implementation for sax parsing is here
https://github.com/dhoerl/SAX-JSON-Parser-ForStreamingData
where the data is parsed as and when the data is received. For more info check this answer iPad - Parsing an extremely huge json - File (between 50 and 100 mb)
Yeah, this is again an Obj-C based approach. I was looking for something Swift based actually. –
Suppose
© 2022 - 2024 — McMap. All rights reserved.
json
from the server in parts. I mean, X number of elements each time – Farant