OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // A JSON parser. Converts strings of JSON into a Value object (see | 5 // A JSON parser. Converts strings of JSON into a Value object (see |
6 // base/values.h). | 6 // base/values.h). |
7 // http://www.ietf.org/rfc/rfc4627.txt?number=4627 | 7 // http://www.ietf.org/rfc/rfc4627.txt?number=4627 |
8 // | 8 // |
9 // Known limitations/deviations from the RFC: | 9 // Known limitations/deviations from the RFC: |
10 // - Only knows how to parse ints within the range of a signed 32 bit int and | 10 // - Only knows how to parse ints within the range of a signed 32 bit int and |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 JSON_UNEXPECTED_TOKEN, | 68 JSON_UNEXPECTED_TOKEN, |
69 JSON_TRAILING_COMMA, | 69 JSON_TRAILING_COMMA, |
70 JSON_TOO_MUCH_NESTING, | 70 JSON_TOO_MUCH_NESTING, |
71 JSON_UNEXPECTED_DATA_AFTER_ROOT, | 71 JSON_UNEXPECTED_DATA_AFTER_ROOT, |
72 JSON_UNSUPPORTED_ENCODING, | 72 JSON_UNSUPPORTED_ENCODING, |
73 JSON_UNQUOTED_DICTIONARY_KEY, | 73 JSON_UNQUOTED_DICTIONARY_KEY, |
74 JSON_PARSE_ERROR_COUNT | 74 JSON_PARSE_ERROR_COUNT |
75 }; | 75 }; |
76 | 76 |
77 // String versions of parse error codes. | 77 // String versions of parse error codes. |
78 static const char* kInvalidEscape; | 78 static const char kInvalidEscape[]; |
79 static const char* kSyntaxError; | 79 static const char kSyntaxError[]; |
80 static const char* kUnexpectedToken; | 80 static const char kUnexpectedToken[]; |
81 static const char* kTrailingComma; | 81 static const char kTrailingComma[]; |
82 static const char* kTooMuchNesting; | 82 static const char kTooMuchNesting[]; |
83 static const char* kUnexpectedDataAfterRoot; | 83 static const char kUnexpectedDataAfterRoot[]; |
84 static const char* kUnsupportedEncoding; | 84 static const char kUnsupportedEncoding[]; |
85 static const char* kUnquotedDictionaryKey; | 85 static const char kUnquotedDictionaryKey[]; |
86 | 86 |
87 // Constructs a reader with the default options, JSON_PARSE_RFC. | 87 // Constructs a reader with the default options, JSON_PARSE_RFC. |
88 JSONReader(); | 88 JSONReader(); |
89 | 89 |
90 // Constructs a reader with custom options. | 90 // Constructs a reader with custom options. |
91 explicit JSONReader(int options); | 91 explicit JSONReader(int options); |
92 | 92 |
93 ~JSONReader(); | 93 ~JSONReader(); |
94 | 94 |
95 // Reads and parses |json|, returning a Value. The caller owns the returned | 95 // Reads and parses |json|, returning a Value. The caller owns the returned |
(...skipping 29 matching lines...) Expand all Loading... |
125 // numbers if appropriate. | 125 // numbers if appropriate. |
126 std::string GetErrorMessage() const; | 126 std::string GetErrorMessage() const; |
127 | 127 |
128 private: | 128 private: |
129 scoped_ptr<internal::JSONParser> parser_; | 129 scoped_ptr<internal::JSONParser> parser_; |
130 }; | 130 }; |
131 | 131 |
132 } // namespace base | 132 } // namespace base |
133 | 133 |
134 #endif // BASE_JSON_JSON_READER_H_ | 134 #endif // BASE_JSON_JSON_READER_H_ |
OLD | NEW |