UNICORN - iOS
|
The JSON writer class. [詳解]
#import <SBJsonWriter.h>
実体メソッド | |
(NSString *) | - stringWithObject: |
Return JSON representation for the given object. [詳解] | |
(NSData *) | - dataWithObject: |
Return JSON representation for the given object. [詳解] | |
(NSString *) | - stringWithObject:error: |
Return JSON representation (or fragment) for the given object. [詳解] | |
プロパティ | |
NSUInteger | maxDepth |
The maximum recursing depth. [詳解] | |
NSString * | error |
Return an error trace, or nil if there was no errors. [詳解] | |
BOOL | humanReadable |
Whether we are generating human-readable (multiline) JSON. [詳解] | |
BOOL | sortKeys |
Whether or not to sort the dictionary keys in the output. [詳解] | |
NSComparator | sortKeysComparator |
An optional comparator to be used if sortKeys is YES. [詳解] | |
- (NSData *) dataWithObject: | (id) | value |
Return JSON representation for the given object.
Returns an NSData object containing JSON represented as UTF8 text, or nil on error.
value | any instance that can be represented as JSON text. |
- (NSString *) stringWithObject: | (id) | value |
Return JSON representation for the given object.
Returns a string containing JSON representation of the passed in value, or nil on error. If nil is returned and error
is not NULL, *error
can be interrogated to find the cause of the error.
value | any instance that can be represented as JSON text. |
- (NSString *) stringWithObject: | (id) | value | |
error: | (NSError**) | error | |
Return JSON representation (or fragment) for the given object.
Returns a string containing JSON representation of the passed in value, or nil on error. If nil is returned and error
is not NULL, *error
can be interrogated to find the cause of the error.
value | any instance that can be represented as a JSON fragment |
error | pointer to object to be populated with NSError on failure |
|
readatomiccopy |
Return an error trace, or nil if there was no errors.
Note that this method returns the trace of the last method that failed. You need to check the return value of the call you're making to figure out if the call actually failed, before you know call this method.
|
readwriteatomic |
Whether we are generating human-readable (multiline) JSON.
Set whether or not to generate human-readable JSON. The default is NO, which produces JSON without any whitespace. (Except inside strings.) If set to YES, generates human-readable JSON with linebreaks after each array value and dictionary key/value pair, indented two spaces per nesting level.
|
readwriteatomic |
The maximum recursing depth.
Defaults to 32. If the input is nested deeper than this the input will be deemed to be malicious and the parser returns nil, signalling an error. ("Nested too deep".) You can turn off this security feature by setting the maxDepth value to 0.
|
readwriteatomic |
Whether or not to sort the dictionary keys in the output.
If this is set to YES, the dictionary keys in the JSON output will be in sorted order. (This is useful if you need to compare two structures, for example.) The default is NO.
|
readwriteatomiccopy |
An optional comparator to be used if sortKeys is YES.
If this is nil, sorting will be done via (compare:).