Playlist Generator  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines
Public Member Functions | Properties
SBJsonWriter Class Reference

The JSON writer class. More...

#import <SBJsonWriter.h>

Inheritance diagram for SBJsonWriter:
NSObject

List of all members.

Public Member Functions

(NSString *) - stringWithObject:
 Return JSON representation for the given object.
(NSData *) - dataWithObject:
 Return JSON representation for the given object.
(NSString *) - stringWithObject:error:
 Return JSON representation (or fragment) for the given object.

Properties

NSUInteger maxDepth
 The maximum recursing depth.
NSStringerror
 Return an error trace, or nil if there was no errors.
BOOL humanReadable
 Whether we are generating human-readable (multiline) JSON.
BOOL sortKeys
 Whether or not to sort the dictionary keys in the output.

Detailed Description

The JSON writer class.

This uses SBJsonStreamWriter internally.

See also:
JSON to Objective-C

Member Function Documentation

- (NSData *) dataWithObject: (id)  value

Return JSON representation for the given object.

Returns an NSData object containing JSON represented as UTF8 text, or nil on error.

Parameters:
valueany instance that can be represented as JSON text.
- (NSString *) stringWithObject: (id)  value

Return JSON representation for the given object.

Returns a string containing JSON representation of the passed in value, or nil on error. If nil is returned and error is not NULL, *error can be interrogated to find the cause of the error.

Parameters:
valueany instance that can be represented as JSON text.
- (NSString *) stringWithObject: (id)  value
error: (NSError**)  error 

Return JSON representation (or fragment) for the given object.

Returns a string containing JSON representation of the passed in value, or nil on error. If nil is returned and error is not NULL, *error can be interrogated to find the cause of the error.

Parameters:
valueany instance that can be represented as a JSON fragment
errorpointer to object to be populated with NSError on failure

Property Documentation

- (NSString*) error [read, copy]

Return an error trace, or nil if there was no errors.

Note that this method returns the trace of the last method that failed. You need to check the return value of the call you're making to figure out if the call actually failed, before you know call this method.

- (BOOL) humanReadable [read, write, assign]

Whether we are generating human-readable (multiline) JSON.

Set whether or not to generate human-readable JSON. The default is NO, which produces JSON without any whitespace. (Except inside strings.) 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]

The maximum recursing depth.

Defaults to 32. 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]

Whether or not to sort the dictionary keys in the output.

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: