UNICORN - iOS
SBJsonStreamWriter.h
1 /*
2  Copyright (c) 2010, Stig Brautaset.
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are
7  met:
8 
9  Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11 
12  Redistributions in binary form must reproduce the above copyright
13  notice, this list of conditions and the following disclaimer in the
14  documentation and/or other materials provided with the distribution.
15 
16  Neither the name of the the author nor the names of its contributors
17  may be used to endorse or promote products derived from this software
18  without specific prior written permission.
19 
20  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #import <Foundation/Foundation.h>
34 
37 
57 - (id)proxyForJson;
58 
59 @end
60 
61 @class SBJsonStreamWriter;
62 
64 
65 - (void)writer:(SBJsonStreamWriter*)writer appendBytes:(const void *)bytes length:(NSUInteger)length;
66 
67 @end
68 
70 
85 @interface SBJsonStreamWriter : NSObject {
86  NSMutableDictionary *cache;
87 }
88 
89 @property (nonatomic, unsafe_unretained) SBJsonStreamWriterState *state; // Internal
90 @property (nonatomic, readonly, strong) NSMutableArray *stateStack; // Internal
91 
96 @property (unsafe_unretained) id<SBJsonStreamWriterDelegate> delegate;
97 
105 @property NSUInteger maxDepth;
106 
115 @property BOOL humanReadable;
116 
123 @property BOOL sortKeys;
124 
130 @property (copy) NSComparator sortKeysComparator;
131 
133 @property (copy) NSString *error;
134 
139 - (BOOL)writeObject:(NSDictionary*)dict;
140 
145 - (BOOL)writeArray:(NSArray *)array;
146 
151 - (BOOL)writeObjectOpen;
152 
157 - (BOOL)writeObjectClose;
158 
162 - (BOOL)writeArrayOpen;
163 
167 - (BOOL)writeArrayClose;
168 
172 - (BOOL)writeNull;
173 
177 - (BOOL)writeBool:(BOOL)x;
178 
182 - (BOOL)writeNumber:(NSNumber*)n;
183 
187 - (BOOL)writeString:(NSString*)s;
188 
189 @end
190 
192 - (BOOL)writeValue:(id)v;
193 - (void)appendBytes:(const void *)bytes length:(NSUInteger)length;
194 @end
195 
BOOL humanReadable
Whether we are generating human-readable (multiline) JSON.
Definition: SBJsonStreamWriter.h:115
Enable JSON writing for non-native objects.
Definition: SBJsonStreamWriter.h:36
The Stream Writer class.
Definition: SBJsonStreamWriter.h:85
BOOL sortKeys
Whether or not to sort the dictionary keys in the output.
Definition: SBJsonStreamWriter.h:123
id proxyForJson()
Allows generation of JSON for otherwise unsupported classes.
Definition: SBJsonStreamWriter.h:191
Definition: SBJsonStreamWriter.h:63
Definition: SBJsonStreamWriterState.h:37
NSUInteger maxDepth
The maximum recursing depth.
Definition: SBJsonStreamWriter.h:105