MSH
MSH

Reputation: 163

How to parse a JSON file line by line in objective c

I am working with very large JSON files, so I do not want to read the entire file and then iterate and parse each data entry. Instead, I would like to iterate on the JSON file itself (for example: line-by-line/one object at a time). I thought about holding the next line location as part of the current line data, so the JSON is a semi linked list, but I did not manage to extract a specific line from the JSON file. Am I missing an easier way to achieve that? Is it even possible to extract and parse a specific line from a JSON file?

Thanks a lot!

Upvotes: 1

Views: 276

Answers (1)

Gereon
Gereon

Reputation: 17872

JSON is not a line oriented format, so the idea of parsing "line by line" doesn't really make sense.

That said, there is at least one event-driven JSON parser for iOS that I know of, https://github.com/stig/json-framework. The built-in parser NSJSONSerialization only works on entire files.

Upvotes: 3

Related Questions