SBJson 3.0.4
|
Parse a stream of JSON data. More...
Inherits NSObject.
List of all members.
Public Member Functions |
|
(SBJsonStreamParserStatus) | - parse: |
Parse some JSON. |
|
Properties |
|
BOOL | supportMultipleDocuments |
Expect multiple documents separated by whitespace. |
|
id< SBJsonStreamParserDelegate > | delegate |
Delegate to receive messages. |
|
NSUInteger | maxDepth |
The max parse depth. |
|
NSString * | error |
Holds the error after SBJsonStreamParserError was returned. |
Using this class directly you can reduce the apparent latency for each download/parse cycle of documents over a slow connection. You can start parsing and return chunks of the parsed document before the entire document is downloaded.
Using this class is also useful to parse huge documents on disk bit by bit so you don't have to keep them all in memory.
- (SBJsonStreamParserStatus) parse: | (NSData*) | data |
The JSON is assumed to be UTF8 encoded. This can be a full JSON document, or a part of one.
data | An NSData object containing the next chunk of JSON |
- (id< SBJsonStreamParserDelegate >) delegate [read, write, assign]
|
The object set here receives a series of messages as the parser breaks down the JSON stream into valid tokens.
- (NSUInteger) maxDepth [read, write, assign]
|
If the input is nested deeper than this the parser will halt parsing and return an error.
Defaults to 32.
- (BOOL) supportMultipleDocuments [read, write, assign]
|
Normally the -parse
: method returns SBJsonStreamParserComplete when it's found a complete JSON document. Attempting to parse any more data at that point is considered an error. ("Garbage after JSON".)
If you set this property to true the parser will never return SBJsonStreamParserComplete. Rather, once an object is completed it will expect another object to immediately follow, separated only by (optional) whitespace.