Statistics
| Branch: | Revision:

root / json-framework-3.2.0 / Classes / SBJsonParser.h @ 3ebe9884

History | View | Annotate | Download (3.5 kB)

1
/*
2
 Copyright (C) 2009 Stig Brautaset. All rights reserved.
3

4
 Redistribution and use in source and binary forms, with or without
5
 modification, are permitted provided that the following conditions are met:
6

7
 * Redistributions of source code must retain the above copyright notice, this
8
   list of conditions and the following disclaimer.
9

10
 * Redistributions in binary form must reproduce the above copyright notice,
11
   this list of conditions and the following disclaimer in the documentation
12
   and/or other materials provided with the distribution.
13

14
 * Neither the name of the author nor the names of its contributors may be used
15
   to endorse or promote products derived from this software without specific
16
   prior written permission.
17

18
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 */
29

    
30
#import <Foundation/Foundation.h>
31

    
32
/**
33
 Parse JSON Strings and NSData objects
34

35
 This uses SBJsonStreamParser internally.
36

37
 */
38

    
39
@interface SBJsonParser : NSObject
40

    
41
/**
42
 The maximum recursing depth.
43

44
 Defaults to 32. If the input is nested deeper than this the input will be deemed to be
45
 malicious and the parser returns nil, signalling an error. ("Nested too deep".) You can
46
 turn off this security feature by setting the maxDepth value to 0.
47
 */
48
@property NSUInteger maxDepth;
49

    
50
/**
51
 Description of parse error
52

53
 This method returns the trace of the last method that failed.
54
 You need to check the return value of the call you're making to figure out
55
 if the call actually failed, before you know call this method.
56

57
 @return A string describing the error encountered, or nil if no error occured.
58

59
 */
60
@property(copy) NSString *error;
61

    
62
/**
63
 Return the object represented by the given NSData object.
64

65
 The data *must* be UTF8 encoded.
66

67
 @param data An NSData containing UTF8 encoded data to parse.
68
 @return The NSArray or NSDictionary represented by the object, or nil if an error occured.
69

70
 */
71
- (id)objectWithData:(NSData*)data;
72

    
73
/**
74
 Return the object represented by the given string
75

76
 This method converts its input to an NSData object containing UTF8 and calls -objectWithData: with it.
77

78
 @return The NSArray or NSDictionary represented by the object, or nil if an error occured.
79
 */
80
- (id)objectWithString:(NSString *)repr;
81

    
82
/**
83
 Return the object represented by the given string
84

85
 This method calls objectWithString: internally. If an error occurs, and if error
86
 is not nil, it creates an NSError object and returns this through its second argument.
87

88
 @param jsonText the json string to parse
89
 @param error pointer to an NSError object to populate on error
90

91
 @return The NSArray or NSDictionary represented by the object, or nil if an error occured.
92

93
 @warning Deprecated in Version 3.2; will be removed in 4.0
94

95
 */
96

    
97
- (id)objectWithString:(NSString*)jsonText
98
                 error:(NSError**)error __attribute__ ((deprecated));
99

    
100
@end
101

    
102