libs-base/Headers/Foundation/NSJSONSerialization.h
David Chisnall c1cca9a336 Added NSJSONSerialization (10.7) implementation. The code path reading from an NSInputStream is not well tested - please try and break it!
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33631 72102866-910b-0410-8b05-ffd578937521
2011-07-25 15:50:51 +00:00

63 lines
1.8 KiB
Objective-C

#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.
*/
@interface NSJSONSerialization : NSObject
+ (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;
@end