Index: base/json/json_reader.h |
diff --git a/base/json/json_reader.h b/base/json/json_reader.h |
index b1edfb07edd4c2bd7c736cb150e24e77703deab0..5f046d66951c6e9a4f8acf606096944d5c11bbeb 100644 |
--- a/base/json/json_reader.h |
+++ b/base/json/json_reader.h |
@@ -50,6 +50,11 @@ namespace base { |
class Value; |
+enum JSONParserOptions { |
+ JSON_PARSE_RFC = 0, |
Mark Mentovai
2012/04/10 21:51:02
…the idea being 0 is strict, and every other weird
Robert Sesek
2012/04/10 22:06:15
Correct. Other weird features may include single-q
|
+ JSON_ALLOW_TRAILING_COMMAS = 1 << 1, |
Mark Mentovai
2012/04/10 21:51:02
Because if so, this should be 1 << 0.
Robert Sesek
2012/04/10 22:06:15
Oops. Forgot to cherry-pick that fix from the rewr
|
+}; |
+ |
class BASE_EXPORT JSONReader { |
public: |
// A struct to hold a JS token. |
@@ -119,16 +124,19 @@ class BASE_EXPORT JSONReader { |
// Reads and parses |json|, returning a Value. The caller owns the returned |
// instance. If |json| is not a properly formed JSON string, returns NULL. |
- // If |allow_trailing_comma| is true, we will ignore trailing commas in |
- // objects and arrays even though this goes against the RFC. |
- static Value* Read(const std::string& json, bool allow_trailing_comma); |
+ static Value* Read(const std::string& json); |
+ |
+ // Reads and parses |json|, returning a Value owned by the caller. The |
+ // parser respects the given |options|. If the input is not properly formed, |
+ // returns NULL. |
+ static Value* Read(const std::string& json, JSONParserOptions options); |
Mark Mentovai
2012/04/10 21:51:02
More importantly, if so, you can’t use JSONParserO
Robert Sesek
2012/04/10 22:06:15
I want C++11 typesafe enums.
|
// Reads and parses |json| like Read(). |error_code_out| and |error_msg_out| |
// are optional. If specified and NULL is returned, they will be populated |
// an error code and a formatted error message (including error location if |
// appropriate). Otherwise, they will be unmodified. |
static Value* ReadAndReturnError(const std::string& json, |
- bool allow_trailing_comma, |
+ JSONParserOptions options, |
int* error_code_out, |
std::string* error_msg_out); |