Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1192)

Side by Side Diff: base/json/json_reader.h

Issue 2475583002: Adds option for JSON reader to allow invalid utf characters (Closed)
Patch Set: unicode Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/json/json_parser_unittest.cc ('k') | base/json/json_string_value_serializer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 JSON_PARSE_RFC = 0, 48 JSON_PARSE_RFC = 0,
49 49
50 // Allows commas to exist after the last element in structures. 50 // Allows commas to exist after the last element in structures.
51 JSON_ALLOW_TRAILING_COMMAS = 1 << 0, 51 JSON_ALLOW_TRAILING_COMMAS = 1 << 0,
52 52
53 // The parser can perform optimizations by placing hidden data in the root of 53 // The parser can perform optimizations by placing hidden data in the root of
54 // the JSON object, which speeds up certain operations on children. However, 54 // the JSON object, which speeds up certain operations on children. However,
55 // if the child is Remove()d from root, it would result in use-after-free 55 // if the child is Remove()d from root, it would result in use-after-free
56 // unless it is DeepCopy()ed or this option is used. 56 // unless it is DeepCopy()ed or this option is used.
57 JSON_DETACHABLE_CHILDREN = 1 << 1, 57 JSON_DETACHABLE_CHILDREN = 1 << 1,
58
59 // If set the parser replaces invalid characters with
60 // kUnicodeReplacementString. If not set, invalid characters trigger a hard
brettw 2016/11/10 20:35:40 This isn't a global constant so it's weird to refe
sky 2016/11/10 23:01:47 Done.
61 // error and parsing fails.
62 JSON_REPLACE_INVALID_CHARACTERS = 1 << 2,
58 }; 63 };
59 64
60 class BASE_EXPORT JSONReader { 65 class BASE_EXPORT JSONReader {
61 public: 66 public:
62 // Error codes during parsing. 67 // Error codes during parsing.
63 enum JsonParseError { 68 enum JsonParseError {
64 JSON_NO_ERROR = 0, 69 JSON_NO_ERROR = 0,
65 JSON_INVALID_ESCAPE, 70 JSON_INVALID_ESCAPE,
66 JSON_SYNTAX_ERROR, 71 JSON_SYNTAX_ERROR,
67 JSON_UNEXPECTED_TOKEN, 72 JSON_UNEXPECTED_TOKEN,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // numbers if appropriate. 132 // numbers if appropriate.
128 std::string GetErrorMessage() const; 133 std::string GetErrorMessage() const;
129 134
130 private: 135 private:
131 std::unique_ptr<internal::JSONParser> parser_; 136 std::unique_ptr<internal::JSONParser> parser_;
132 }; 137 };
133 138
134 } // namespace base 139 } // namespace base
135 140
136 #endif // BASE_JSON_JSON_READER_H_ 141 #endif // BASE_JSON_JSON_READER_H_
OLDNEW
« no previous file with comments | « base/json/json_parser_unittest.cc ('k') | base/json/json_string_value_serializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698