Couchbase Lite
Objective-C API for iOS and Mac OS
Class Methods | List of all members
CBLJSON Class Reference

Useful extensions for JSON serialization/parsing. More...

#import <CBLJSON.h>

Inheritance diagram for CBLJSON:

Class Methods

(NSString *) + stringWithJSONObject:options:error:
 Same as -dataWithJSONObject... More...
 
(NSData *) + appendDictionary:toJSONDictionaryData:
 Given valid JSON data representing a dictionary, inserts the contents of the given NSDictionary into it and returns the resulting JSON data. More...
 
(NSString *) + JSONObjectWithDate:
 Encodes an NSDate as a string in ISO-8601 format. More...
 
(NSDate *) + dateWithJSONObject:
 Parses an ISO-8601 formatted date string to an NSDate object. More...
 
(CFAbsoluteTime) + absoluteTimeWithJSONObject:
 Parses an ISO-8601 formatted date string to an absolute time (timeSinceReferenceDate). More...
 
(id) + valueAtPointer:inObject:
 Follows a JSON-Pointer, returning the value pointed to, or nil if nothing. More...
 
(NSString *) + base64StringWithData:
 Encodes an NSData as a string in Base64 format. More...
 
(NSData *) + dataWithBase64String:
 Parses a Base64-encoded string into an NSData object. More...
 

Detailed Description

Useful extensions for JSON serialization/parsing.

Method Documentation

+ (NSString*) stringWithJSONObject: (id)  obj
options: (CBLJSONWritingOptions opt
error: (NSError **)  error 

Same as -dataWithJSONObject...

but returns an NSString.

+ (NSData*) appendDictionary: (NSDictionary *)  dict
toJSONDictionaryData: (NSData *)  json 

Given valid JSON data representing a dictionary, inserts the contents of the given NSDictionary into it and returns the resulting JSON data.

This does not parse or regenerate the JSON, so it's quite fast. But it will generate invalid JSON if the input JSON begins or ends with whitespace, or if the dictionary contains any keys that are already in the original JSON.

+ (NSString*) JSONObjectWithDate: (NSDate *)  date

Encodes an NSDate as a string in ISO-8601 format.

+ (NSDate*) dateWithJSONObject: (id)  jsonObject

Parses an ISO-8601 formatted date string to an NSDate object.

If the object is not a string, or not valid ISO-8601, it returns nil.

+ (CFAbsoluteTime) absoluteTimeWithJSONObject: (id)  jsonObject

Parses an ISO-8601 formatted date string to an absolute time (timeSinceReferenceDate).

If the object is not a string, or not valid ISO-8601, it returns a NAN value.

+ (id) valueAtPointer: (NSString *)  pointer
inObject: (id)  object 

Follows a JSON-Pointer, returning the value pointed to, or nil if nothing.

See spec at: http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-04

+ (NSString*) base64StringWithData: (NSData *)  data

Encodes an NSData as a string in Base64 format.

+ (NSData*) dataWithBase64String: (id)  jsonObject

Parses a Base64-encoded string into an NSData object.

If the object is not a string, or not valid Base64, it returns nil.


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