mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
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
This commit is contained in:
parent
d1ab6b2dba
commit
c1cca9a336
6 changed files with 1011 additions and 0 deletions
63
Headers/Foundation/NSJSONSerialization.h
Normal file
63
Headers/Foundation/NSJSONSerialization.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
#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
|
Loading…
Add table
Add a link
Reference in a new issue