2011-07-25 15:50:51 +00:00
|
|
|
#import "Foundation/NSObject.h"
|
|
|
|
|
|
|
|
@class NSData;
|
|
|
|
@class NSError;
|
|
|
|
@class NSInputStream;
|
|
|
|
@class NSOutputStream;
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Collection classes created from reading a JSON stream will be mutable.
|
|
|
|
*/
|
|
|
|
NSJSONReadingMutableContainers = (1UL << 0),
|
|
|
|
/**
|
|
|
|
* Strings in a JSON tree will be mutable.
|
|
|
|
*/
|
|
|
|
NSJSONReadingMutableLeaves = (1UL << 1),
|
|
|
|
/**
|
|
|
|
* The parser will read a single value, not just a
|
|
|
|
*/
|
|
|
|
NSJSONReadingAllowFragments = (1UL << 2)
|
|
|
|
};
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* When writing JSON, produce indented output intended for humans to read.
|
|
|
|
* If this is not set, then the writer will not generate any superfluous
|
|
|
|
* whitespace, producing space-efficient but not very human-friendly JSON.
|
|
|
|
*/
|
|
|
|
NSJSONWritingPrettyPrinted = (1UL << 0)
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* A bitmask containing flags from the NSJSONWriting* set, specifying options
|
|
|
|
* to use when writing JSON.
|
|
|
|
*/
|
|
|
|
typedef NSUInteger NSJSONWritingOptions;
|
|
|
|
/**
|
|
|
|
* A bitmask containing flags from the NSJSONReading* set, specifying options
|
|
|
|
* to use when reading JSON.
|
|
|
|
*/
|
|
|
|
typedef NSUInteger NSJSONReadingOptions;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NSJSONSerialization implements serializing and deserializing acyclic object
|
|
|
|
* graphs in JSON.
|
|
|
|
*/
|
2021-01-18 13:20:14 +00:00
|
|
|
GS_EXPORT_CLASS
|
2011-07-25 15:50:51 +00:00
|
|
|
@interface NSJSONSerialization : NSObject
|
2021-11-29 14:01:13 +00:00
|
|
|
+ (NSData*) dataWithJSONObject: (id)obj
|
|
|
|
options: (NSJSONWritingOptions)opt
|
|
|
|
error: (NSError **)error;
|
|
|
|
+ (BOOL) isValidJSONObject: (id)obj;
|
|
|
|
+ (id) JSONObjectWithData: (NSData *)data
|
|
|
|
options: (NSJSONReadingOptions)opt
|
|
|
|
error: (NSError **)error;
|
|
|
|
+ (id) JSONObjectWithStream: (NSInputStream *)stream
|
|
|
|
options: (NSJSONReadingOptions)opt
|
|
|
|
error: (NSError **)error;
|
|
|
|
+ (NSInteger) writeJSONObject: (id)obj
|
|
|
|
toStream: (NSOutputStream *)stream
|
|
|
|
options: (NSJSONWritingOptions)opt
|
|
|
|
error: (NSError **)error;
|
2011-07-25 15:50:51 +00:00
|
|
|
@end
|