AFNetworking does not have a JSON-style SAX streaming built-in, but it must be direct in order to create its own.
- Create a subclass of
AFJSONRequestOperation
- Use the
outputStream
property of the operation during initialization to connect it to a JSON parser that supports SAX-style parsing (for example, Yajl ). The analyzer will read the data and create a JSON object, since it is included in - Connect the
responseJSON
property to read the cached object from the analyzer - ... or depending on how you do streaming, you may need to add a new property that defines the block to execute when new JSON objects are returned (e.g.
setReceivedJSONBlock:((^)(void (id JSON))block
) This block is likely to be called by delegation methods sent from the analyzer (for example, <YAJLParserDelegate> -parserDidEndDictionary:
.
If you can achieve this, I would recommend that you publish and share this with others. I think this can be useful for many people.
mattt source share