Inherits from NSObject
Declared in SBJsonParser.h

Overview

Parse JSON Strings and NSData objects

This uses SBJsonStreamParser internally.

Tasks

Properties

error

Description of parse error

@property (copy) NSString *error

Return Value

A string describing the error encountered, or nil if no error occured.

Discussion

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.

Declared In

SBJsonParser.h

maxDepth

The maximum recursing depth.

@property NSUInteger maxDepth

Discussion

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.

Declared In

SBJsonParser.h

Instance Methods

objectWithData:

Return the object represented by the given NSData object.

- (id)objectWithData:(NSData *)data

Parameters

data

An NSData containing UTF8 encoded data to parse.

Return Value

The NSArray or NSDictionary represented by the object, or nil if an error occured.

Discussion

The data must be UTF8 encoded.

Declared In

SBJsonParser.h

objectWithString:

Return the object represented by the given string

- (id)objectWithString:(NSString *)repr

Return Value

The NSArray or NSDictionary represented by the object, or nil if an error occured.

Discussion

This method converts its input to an NSData object containing UTF8 and calls objectWithData: with it.

Declared In

SBJsonParser.h

objectWithString:error:

Return the object represented by the given string

- (id)objectWithString:(NSString *)jsonText error:(NSError **)error

Parameters

jsonText

the json string to parse

error

pointer to an NSError object to populate on error

Return Value

The NSArray or NSDictionary represented by the object, or nil if an error occured.

Discussion

This method calls objectWithString: internally. If an error occurs, and if error is not nil, it creates an NSError object and returns this through its second argument.

Warning: Deprecated in Version 3.2; will be removed in 4.0

Declared In

SBJsonParser.h