GCKJSONUtils Class Reference

Utility methods for working with JSON data. More...

#import <GCKJSONUtils.h>

+ Inheritance diagram for GCKJSONUtils:

Class Methods

(id GCK_NULLABLE_TYPE) + parseJSON:
 Parses a JSON string into an object. More...
 
(id GCK_NULLABLE_TYPE) + parseJSON:error:
 Parses a JSON string into an object. More...
 
(NSString *) + writeJSON:
 Writes an object hierarchy of data to a JSON string. More...
 
(BOOL) + isJSONString:equivalentTo:
 Tests if two JSON strings are equivalent. More...
 
(BOOL) + isJSONObject:equivalentTo:
 Tests if two JSON objects are equivalent. More...
 

Detailed Description

Utility methods for working with JSON data.

Method Documentation

+ (BOOL) isJSONObject: (id)  actual
equivalentTo: (id)  expected 

Tests if two JSON objects are equivalent.

This does a deep comparison of the JSON data in the two objects, but ignores any differences in the ordering of keys within a JSON object. For example, { "width":64, "height":32 } is considered to be equivalent to { "height":32, "width":64 }.

+ (BOOL) isJSONString: (NSString *)  actual
equivalentTo: (NSString *)  expected 

Tests if two JSON strings are equivalent.

This does a deep comparison of the JSON data in the two strings, but ignores any differences in the ordering of keys within a JSON object. For example, { "width":64, "height":32 } is considered to be equivalent to { "height":32, "width":64 }.

+ (id GCK_NULLABLE_TYPE) parseJSON: (NSString *)  json

Parses a JSON string into an object.

Parameters
jsonThe JSON string to parse.
Returns
The root object of the object hierarchy that represents the data (either an NSArray or an NSDictionary), or nil if the parsing failed.
+ (id GCK_NULLABLE_TYPE) parseJSON: (NSString *)  json
error: (NSError **)  error 

Parses a JSON string into an object.

Parameters
jsonThe JSON string to parse.
errorIf not nil, the location at which to store a pointer to an NSError if the parsing fails.
Returns
The root object of the object hierarchy that represents the data (either an NSArray or an NSDictionary), or nil if the parsing failed.
+ (NSString *) writeJSON: (id)  object

Writes an object hierarchy of data to a JSON string.

Parameters
objectThe root object of the object hierarchy to encode. This must be either an NSArray or an NSDictionary.
Returns
An NSString containing the JSON encoding, or nil if the data could not be encoded.

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