SBJson 3.0.4
|
The Stream Writer class. More...
Inherits NSObject.
List of all members.
Public Member Functions |
|
(BOOL) | - writeObject: |
(BOOL) | - writeArray: |
(BOOL) | - writeObjectOpen |
(BOOL) | - writeObjectClose |
(BOOL) | - writeArrayOpen |
(BOOL) | - writeArrayClose |
(BOOL) | - writeNull |
(BOOL) | - writeBool: |
(BOOL) | - writeNumber: |
(BOOL) | - writeString: |
Properties |
|
id< SBJsonStreamWriterDelegate > | delegate |
delegate to receive JSON output Delegate that will receive messages with output. |
|
NSUInteger | maxDepth |
The maximum recursing depth. |
|
BOOL | humanReadable |
Whether we are generating human-readable (multiline) JSON. |
|
BOOL | sortKeys |
Whether or not to sort the dictionary keys in the output. |
|
NSString * | error |
Contains the error description after an error has occured. |
Accepts a stream of messages and writes JSON of these to its delegate object.
This class provides a range of high-, mid- and low-level methods. You can mix and match calls to these. For example, you may want to call -writeArrayOpen to start an array and then repeatedly call -writeObject: with various objects before finishing off with a -writeArrayClose call.
- (BOOL) writeArray: | (NSArray *) | array |
Write an NSArray to the JSON stream.
- (BOOL) writeArrayClose |
Close the current Array being written
- (BOOL) writeArrayOpen |
Start writing an Array to the stream
- (BOOL) writeBool: | (BOOL) | x |
Write a boolean to the stream
- (BOOL) writeNull |
Write a null to the stream
- (BOOL) writeNumber: | (NSNumber*) | n |
Write a Number to the stream
- (BOOL) writeObject: | (NSDictionary*) | dict |
Write an NSDictionary to the JSON stream.
- (BOOL) writeObjectClose |
Close the current object being written
- (BOOL) writeObjectOpen |
Start writing an Object to the stream
- (BOOL) writeString: | (NSString*) | s |
Write a String to the stream
- (BOOL) humanReadable [read, write, assign]
|
Set whether or not to generate human-readable JSON. The default is NO, which produces JSON without any whitespace between tokens. If set to YES, generates human-readable JSON with linebreaks after each array value and dictionary key/value pair, indented two spaces per nesting level.
- (NSUInteger) maxDepth [read, write, assign]
|
Defaults to 512. If the input is nested deeper than this the input will be deemed to be malicious and the parser returns nil, signalling an error. ("Nested too deep".) You can turn off this security feature by setting the maxDepth value to 0.
- (BOOL) sortKeys [read, write, assign]
|
If this is set to YES, the dictionary keys in the JSON output will be in sorted order. (This is useful if you need to compare two structures, for example.) The default is NO.