SBJson  3.0.4
Public Member Functions | Properties
SBJsonStreamWriter Class Reference

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.

Detailed Description

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.

See also:
JSON to Objective-C

Member Function Documentation

- (BOOL) writeArray: (NSArray *)  array

Write an NSArray to the JSON stream.

Returns:
YES if successful, or NO on failure
- (BOOL) writeArrayClose

Close the current Array being written

Returns:
YES if successful, or NO on failure
- (BOOL) writeArrayOpen

Start writing an Array to the stream

Returns:
YES if successful, or NO on failure
- (BOOL) writeBool: (BOOL)  x

Write a boolean to the stream

Returns:
YES if successful, or NO on failure
- (BOOL) writeNull

Write a null to the stream

Returns:
YES if successful, or NO on failure
- (BOOL) writeNumber: (NSNumber*)  n

Write a Number to the stream

Returns:
YES if successful, or NO on failure
- (BOOL) writeObject: (NSDictionary*)  dict

Write an NSDictionary to the JSON stream.

Returns:
YES if successful, or NO on failure
- (BOOL) writeObjectClose

Close the current object being written

Returns:
YES if successful, or NO on failure
- (BOOL) writeObjectOpen

Start writing an Object to the stream

Returns:
YES if successful, or NO on failure
- (BOOL) writeString: (NSString*)  s

Write a String to the stream

Returns:
YES if successful, or NO on failure

Property Documentation

- (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.


The documentation for this class was generated from the following files: