diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-11 00:15:41 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-11 00:15:41 +0000 |
commit | cd57857578b7b905ee27580d8ca279f6f7642e82 (patch) | |
tree | 82230a21554f358452b508ee64ef1ea3efcb518b | |
parent | cc7cde43832b547cdab856fe1bedc9514ca38e13 (diff) | |
download | chromium_src-cd57857578b7b905ee27580d8ca279f6f7642e82.zip chromium_src-cd57857578b7b905ee27580d8ca279f6f7642e82.tar.gz chromium_src-cd57857578b7b905ee27580d8ca279f6f7642e82.tar.bz2 |
Modify the base::JSONReader interface to take a set of options rather than a boolean flag.
This is just prep work for a large CL that rewrites the JSON parser. Splitting
out this interface change will make it easier to review the other CL.
BUG=121469
TEST=No functional change.
Review URL: https://chromiumcodereview.appspot.com/9960077
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131680 0039d316-1c4b-4281-b951-d872f2087c98
74 files changed, 210 insertions, 208 deletions
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc index b85b468..66dff0d 100644 --- a/base/debug/trace_event_unittest.cc +++ b/base/debug/trace_event_unittest.cc @@ -99,7 +99,7 @@ void TraceEventTestFixture::OnTraceDataCollected( trace_buffer_.Finish(); scoped_ptr<Value> root; - root.reset(base::JSONReader::Read(json_output_.json_output, false)); + root.reset(base::JSONReader::Read(json_output_.json_output)); if (!root.get()) { LOG(ERROR) << json_output_.json_output; diff --git a/base/json/json_reader.cc b/base/json/json_reader.cc index c9f6e76..3457478 100644 --- a/base/json/json_reader.cc +++ b/base/json/json_reader.cc @@ -93,18 +93,24 @@ JSONReader::JSONReader() error_col_(0) {} // static +Value* JSONReader::Read(const std::string& json) { + return Read(json, JSON_PARSE_RFC); +} + +// static Value* JSONReader::Read(const std::string& json, - bool allow_trailing_comma) { - return ReadAndReturnError(json, allow_trailing_comma, NULL, NULL); + int options) { + return ReadAndReturnError(json, options, NULL, NULL); } // static Value* JSONReader::ReadAndReturnError(const std::string& json, - bool allow_trailing_comma, + int options, int* error_code_out, std::string* error_msg_out) { JSONReader reader = JSONReader(); - Value* root = reader.JsonToValue(json, true, allow_trailing_comma); + Value* root = reader.JsonToValue(json, false, + (options & JSON_ALLOW_TRAILING_COMMAS) != 0); if (root) return root; diff --git a/base/json/json_reader.h b/base/json/json_reader.h index b1edfb0..35ee7d3 100644 --- a/base/json/json_reader.h +++ b/base/json/json_reader.h @@ -50,6 +50,15 @@ namespace base { class Value; +enum JSONParserOptions { + // Parses the input strictly according to RFC 4627, except for where noted + // above. + JSON_PARSE_RFC = 0, + + // Allows commas to exist after the last element in structures. + JSON_ALLOW_TRAILING_COMMAS = 1 << 0, +}; + class BASE_EXPORT JSONReader { public: // A struct to hold a JS token. @@ -119,16 +128,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, int options); // 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, + int options, // JSONParserOptions int* error_code_out, std::string* error_msg_out); diff --git a/base/json/json_reader_unittest.cc b/base/json/json_reader_unittest.cc index 467bf4d..4d6b0c4 100644 --- a/base/json/json_reader_unittest.cc +++ b/base/json/json_reader_unittest.cc @@ -224,7 +224,7 @@ TEST(JSONReaderTest, Reading) { EXPECT_FALSE(root.get()); // Basic array - root.reset(JSONReader::Read("[true, false, null]", false)); + root.reset(JSONReader::Read("[true, false, null]")); ASSERT_TRUE(root.get()); EXPECT_TRUE(root->IsType(Value::TYPE_LIST)); ListValue* list = static_cast<ListValue*>(root.get()); @@ -232,19 +232,19 @@ TEST(JSONReaderTest, Reading) { // Test with trailing comma. Should be parsed the same as above. scoped_ptr<Value> root2; - root2.reset(JSONReader::Read("[true, false, null, ]", true)); + root2.reset(JSONReader::Read("[true, false, null, ]", + JSON_ALLOW_TRAILING_COMMAS)); EXPECT_TRUE(root->Equals(root2.get())); // Empty array - root.reset(JSONReader::Read("[]", false)); + root.reset(JSONReader::Read("[]")); ASSERT_TRUE(root.get()); EXPECT_TRUE(root->IsType(Value::TYPE_LIST)); list = static_cast<ListValue*>(root.get()); EXPECT_EQ(0U, list->GetSize()); // Nested arrays - root.reset(JSONReader::Read("[[true], [], [false, [], [null]], null]", - false)); + root.reset(JSONReader::Read("[[true], [], [false, [], [null]], null]")); ASSERT_TRUE(root.get()); EXPECT_TRUE(root->IsType(Value::TYPE_LIST)); list = static_cast<ListValue*>(root.get()); @@ -252,29 +252,29 @@ TEST(JSONReaderTest, Reading) { // Lots of trailing commas. root2.reset(JSONReader::Read("[[true], [], [false, [], [null, ] , ], null,]", - true)); + JSON_ALLOW_TRAILING_COMMAS)); EXPECT_TRUE(root->Equals(root2.get())); // Invalid, missing close brace. - root.reset(JSONReader::Read("[[true], [], [false, [], [null]], null", false)); + root.reset(JSONReader::Read("[[true], [], [false, [], [null]], null")); EXPECT_FALSE(root.get()); // Invalid, too many commas - root.reset(JSONReader::Read("[true,, null]", false)); + root.reset(JSONReader::Read("[true,, null]")); EXPECT_FALSE(root.get()); - root.reset(JSONReader::Read("[true,, null]", true)); + root.reset(JSONReader::Read("[true,, null]", JSON_ALLOW_TRAILING_COMMAS)); EXPECT_FALSE(root.get()); // Invalid, no commas - root.reset(JSONReader::Read("[true null]", false)); + root.reset(JSONReader::Read("[true null]")); EXPECT_FALSE(root.get()); // Invalid, trailing comma - root.reset(JSONReader::Read("[true,]", false)); + root.reset(JSONReader::Read("[true,]")); EXPECT_FALSE(root.get()); // Valid if we set |allow_trailing_comma| to true. - root.reset(JSONReader::Read("[true,]", true)); + root.reset(JSONReader::Read("[true,]", JSON_ALLOW_TRAILING_COMMAS)); ASSERT_TRUE(root.get()); EXPECT_TRUE(root->IsType(Value::TYPE_LIST)); list = static_cast<ListValue*>(root.get()); @@ -288,22 +288,22 @@ TEST(JSONReaderTest, Reading) { // Don't allow empty elements, even if |allow_trailing_comma| is // true. - root.reset(JSONReader::Read("[,]", true)); + root.reset(JSONReader::Read("[,]", JSON_ALLOW_TRAILING_COMMAS)); EXPECT_FALSE(root.get()); - root.reset(JSONReader::Read("[true,,]", true)); + root.reset(JSONReader::Read("[true,,]", JSON_ALLOW_TRAILING_COMMAS)); EXPECT_FALSE(root.get()); - root.reset(JSONReader::Read("[,true,]", true)); + root.reset(JSONReader::Read("[,true,]", JSON_ALLOW_TRAILING_COMMAS)); EXPECT_FALSE(root.get()); - root.reset(JSONReader::Read("[true,,false]", true)); + root.reset(JSONReader::Read("[true,,false]", JSON_ALLOW_TRAILING_COMMAS)); EXPECT_FALSE(root.get()); // Test objects - root.reset(JSONReader::Read("{}", false)); + root.reset(JSONReader::Read("{}")); ASSERT_TRUE(root.get()); EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); root.reset(JSONReader::Read( - "{\"number\":9.87654321, \"null\":null , \"\\x53\" : \"str\" }", false)); + "{\"number\":9.87654321, \"null\":null , \"\\x53\" : \"str\" }")); ASSERT_TRUE(root.get()); EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); DictionaryValue* dict_val = static_cast<DictionaryValue*>(root.get()); @@ -318,7 +318,8 @@ TEST(JSONReaderTest, Reading) { EXPECT_EQ("str", str_val); root2.reset(JSONReader::Read( - "{\"number\":9.87654321, \"null\":null , \"\\x53\" : \"str\", }", true)); + "{\"number\":9.87654321, \"null\":null , \"\\x53\" : \"str\", }", + JSON_ALLOW_TRAILING_COMMAS)); ASSERT_TRUE(root2.get()); EXPECT_TRUE(root->Equals(root2.get())); @@ -328,7 +329,7 @@ TEST(JSONReaderTest, Reading) { " \"number\":9.87654321,\n" " \"null\":null,\n" " \"\\x53\":\"str\",\n" - "}\n", true)); + "}\n", JSON_ALLOW_TRAILING_COMMAS)); ASSERT_TRUE(root2.get()); EXPECT_TRUE(root->Equals(root2.get())); @@ -337,13 +338,13 @@ TEST(JSONReaderTest, Reading) { " \"number\":9.87654321,\r\n" " \"null\":null,\r\n" " \"\\x53\":\"str\",\r\n" - "}\r\n", true)); + "}\r\n", JSON_ALLOW_TRAILING_COMMAS)); ASSERT_TRUE(root2.get()); EXPECT_TRUE(root->Equals(root2.get())); // Test nesting root.reset(JSONReader::Read( - "{\"inner\":{\"array\":[true]},\"false\":false,\"d\":{}}", false)); + "{\"inner\":{\"array\":[true]},\"false\":false,\"d\":{}}")); ASSERT_TRUE(root.get()); EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); dict_val = static_cast<DictionaryValue*>(root.get()); @@ -359,12 +360,13 @@ TEST(JSONReaderTest, Reading) { EXPECT_TRUE(dict_val->GetDictionary("d", &inner_dict)); root2.reset(JSONReader::Read( - "{\"inner\": {\"array\":[true] , },\"false\":false,\"d\":{},}", true)); + "{\"inner\": {\"array\":[true] , },\"false\":false,\"d\":{},}", + JSON_ALLOW_TRAILING_COMMAS)); EXPECT_TRUE(root->Equals(root2.get())); // Test keys with periods root.reset(JSONReader::Read( - "{\"a.b\":3,\"c\":2,\"d.e.f\":{\"g.h.i.j\":1}}", false)); + "{\"a.b\":3,\"c\":2,\"d.e.f\":{\"g.h.i.j\":1}}")); ASSERT_TRUE(root.get()); EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); dict_val = static_cast<DictionaryValue*>(root.get()); @@ -381,7 +383,7 @@ TEST(JSONReaderTest, Reading) { &integer_value)); EXPECT_EQ(1, integer_value); - root.reset(JSONReader::Read("{\"a\":{\"b\":2},\"a.b\":1}", false)); + root.reset(JSONReader::Read("{\"a\":{\"b\":2},\"a.b\":1}")); ASSERT_TRUE(root.get()); EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); dict_val = static_cast<DictionaryValue*>(root.get()); @@ -391,43 +393,45 @@ TEST(JSONReaderTest, Reading) { EXPECT_EQ(1, integer_value); // Invalid, no closing brace - root.reset(JSONReader::Read("{\"a\": true", false)); + root.reset(JSONReader::Read("{\"a\": true")); EXPECT_FALSE(root.get()); // Invalid, keys must be quoted - root.reset(JSONReader::Read("{foo:true}", false)); + root.reset(JSONReader::Read("{foo:true}")); EXPECT_FALSE(root.get()); // Invalid, trailing comma - root.reset(JSONReader::Read("{\"a\":true,}", false)); + root.reset(JSONReader::Read("{\"a\":true,}")); EXPECT_FALSE(root.get()); // Invalid, too many commas - root.reset(JSONReader::Read("{\"a\":true,,\"b\":false}", false)); + root.reset(JSONReader::Read("{\"a\":true,,\"b\":false}")); EXPECT_FALSE(root.get()); - root.reset(JSONReader::Read("{\"a\":true,,\"b\":false}", true)); + root.reset(JSONReader::Read("{\"a\":true,,\"b\":false}", + JSON_ALLOW_TRAILING_COMMAS)); EXPECT_FALSE(root.get()); // Invalid, no separator - root.reset(JSONReader::Read("{\"a\" \"b\"}", false)); + root.reset(JSONReader::Read("{\"a\" \"b\"}")); EXPECT_FALSE(root.get()); // Invalid, lone comma. - root.reset(JSONReader::Read("{,}", false)); + root.reset(JSONReader::Read("{,}")); EXPECT_FALSE(root.get()); - root.reset(JSONReader::Read("{,}", true)); + root.reset(JSONReader::Read("{,}", JSON_ALLOW_TRAILING_COMMAS)); EXPECT_FALSE(root.get()); - root.reset(JSONReader::Read("{\"a\":true,,}", true)); + root.reset(JSONReader::Read("{\"a\":true,,}", JSON_ALLOW_TRAILING_COMMAS)); EXPECT_FALSE(root.get()); - root.reset(JSONReader::Read("{,\"a\":true}", true)); + root.reset(JSONReader::Read("{,\"a\":true}", JSON_ALLOW_TRAILING_COMMAS)); EXPECT_FALSE(root.get()); - root.reset(JSONReader::Read("{\"a\":true,,\"b\":false}", true)); + root.reset(JSONReader::Read("{\"a\":true,,\"b\":false}", + JSON_ALLOW_TRAILING_COMMAS)); EXPECT_FALSE(root.get()); // Test stack overflow std::string evil(1000000, '['); evil.append(std::string(1000000, ']')); - root.reset(JSONReader::Read(evil, false)); + root.reset(JSONReader::Read(evil)); EXPECT_FALSE(root.get()); // A few thousand adjacent lists is fine. @@ -437,7 +441,7 @@ TEST(JSONReaderTest, Reading) { not_evil.append("[],"); } not_evil.append("[]]"); - root.reset(JSONReader::Read(not_evil, false)); + root.reset(JSONReader::Read(not_evil)); ASSERT_TRUE(root.get()); EXPECT_TRUE(root->IsType(Value::TYPE_LIST)); list = static_cast<ListValue*>(root.get()); @@ -491,16 +495,6 @@ TEST(JSONReaderTest, Reading) { root.reset(JSONReader().JsonToValue(cases[i], false, false)); EXPECT_FALSE(root.get()) << cases[i]; } - - // Test invalid root objects. - root.reset(JSONReader::Read("null", false)); - EXPECT_FALSE(root.get()); - root.reset(JSONReader::Read("true", false)); - EXPECT_FALSE(root.get()); - root.reset(JSONReader::Read("10", false)); - EXPECT_FALSE(root.get()); - root.reset(JSONReader::Read("\"root\"", false)); - EXPECT_FALSE(root.get()); } TEST(JSONReaderTest, ReadFromFile) { @@ -515,7 +509,9 @@ TEST(JSONReaderTest, ReadFromFile) { path.Append(FILE_PATH_LITERAL("bom_feff.json")), &input)); JSONReader reader; - scoped_ptr<Value> root(reader.JsonToValue(input, false, false)); + std::string error_msg; + scoped_ptr<Value> root( + JSONReader::ReadAndReturnError(input, JSON_PARSE_RFC, NULL, &error_msg)); ASSERT_TRUE(root.get()) << reader.GetErrorMessage(); EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); } @@ -525,7 +521,7 @@ TEST(JSONReaderTest, ErrorMessages) { std::string error_message; int error_code = 0; scoped_ptr<Value> root; - root.reset(JSONReader::ReadAndReturnError("[42]", false, + root.reset(JSONReader::ReadAndReturnError("[42]", JSON_PARSE_RFC, &error_code, &error_message)); EXPECT_TRUE(error_message.empty()); EXPECT_EQ(0, error_code); @@ -533,7 +529,7 @@ TEST(JSONReaderTest, ErrorMessages) { // Test line and column counting const char* big_json = "[\n0,\n1,\n2,\n3,4,5,6 7,\n8,\n9\n]"; // error here --------------------------------^ - root.reset(JSONReader::ReadAndReturnError(big_json, false, + root.reset(JSONReader::ReadAndReturnError(big_json, JSON_PARSE_RFC, &error_code, &error_message)); EXPECT_FALSE(root.get()); EXPECT_EQ(JSONReader::FormatErrorMessage(5, 9, JSONReader::kSyntaxError), @@ -541,7 +537,7 @@ TEST(JSONReaderTest, ErrorMessages) { EXPECT_EQ(JSONReader::JSON_SYNTAX_ERROR, error_code); // Test each of the error conditions - root.reset(JSONReader::ReadAndReturnError("{},{}", false, + root.reset(JSONReader::ReadAndReturnError("{},{}", JSON_PARSE_RFC, &error_code, &error_message)); EXPECT_FALSE(root.get()); EXPECT_EQ(JSONReader::FormatErrorMessage(1, 3, @@ -553,62 +549,57 @@ TEST(JSONReaderTest, ErrorMessages) { nested_json.insert(nested_json.begin(), '['); nested_json.append(1, ']'); } - root.reset(JSONReader::ReadAndReturnError(nested_json, false, + root.reset(JSONReader::ReadAndReturnError(nested_json, JSON_PARSE_RFC, &error_code, &error_message)); EXPECT_FALSE(root.get()); EXPECT_EQ(JSONReader::FormatErrorMessage(1, 101, JSONReader::kTooMuchNesting), error_message); EXPECT_EQ(JSONReader::JSON_TOO_MUCH_NESTING, error_code); - root.reset(JSONReader::ReadAndReturnError("42", false, - &error_code, &error_message)); - EXPECT_FALSE(root.get()); - EXPECT_EQ(JSONReader::FormatErrorMessage(1, 1, - JSONReader::kBadRootElementType), error_message); - EXPECT_EQ(JSONReader::JSON_BAD_ROOT_ELEMENT_TYPE, error_code); - - root.reset(JSONReader::ReadAndReturnError("[1,]", false, + root.reset(JSONReader::ReadAndReturnError("[1,]", JSON_PARSE_RFC, &error_code, &error_message)); EXPECT_FALSE(root.get()); EXPECT_EQ(JSONReader::FormatErrorMessage(1, 4, JSONReader::kTrailingComma), error_message); EXPECT_EQ(JSONReader::JSON_TRAILING_COMMA, error_code); - root.reset(JSONReader::ReadAndReturnError("{foo:\"bar\"}", false, + root.reset(JSONReader::ReadAndReturnError("{foo:\"bar\"}", JSON_PARSE_RFC, &error_code, &error_message)); EXPECT_FALSE(root.get()); EXPECT_EQ(JSONReader::FormatErrorMessage(1, 2, JSONReader::kUnquotedDictionaryKey), error_message); EXPECT_EQ(JSONReader::JSON_UNQUOTED_DICTIONARY_KEY, error_code); - root.reset(JSONReader::ReadAndReturnError("{\"foo\":\"bar\",}", false, - &error_code, &error_message)); + root.reset(JSONReader::ReadAndReturnError("{\"foo\":\"bar\",}", + JSON_PARSE_RFC, + &error_code, + &error_message)); EXPECT_FALSE(root.get()); EXPECT_EQ(JSONReader::FormatErrorMessage(1, 14, JSONReader::kTrailingComma), error_message); - root.reset(JSONReader::ReadAndReturnError("[nu]", false, + root.reset(JSONReader::ReadAndReturnError("[nu]", JSON_PARSE_RFC, &error_code, &error_message)); EXPECT_FALSE(root.get()); EXPECT_EQ(JSONReader::FormatErrorMessage(1, 2, JSONReader::kSyntaxError), error_message); EXPECT_EQ(JSONReader::JSON_SYNTAX_ERROR, error_code); - root.reset(JSONReader::ReadAndReturnError("[\"xxx\\xq\"]", false, + root.reset(JSONReader::ReadAndReturnError("[\"xxx\\xq\"]", JSON_PARSE_RFC, &error_code, &error_message)); EXPECT_FALSE(root.get()); EXPECT_EQ(JSONReader::FormatErrorMessage(1, 7, JSONReader::kInvalidEscape), error_message); EXPECT_EQ(JSONReader::JSON_INVALID_ESCAPE, error_code); - root.reset(JSONReader::ReadAndReturnError("[\"xxx\\uq\"]", false, + root.reset(JSONReader::ReadAndReturnError("[\"xxx\\uq\"]", JSON_PARSE_RFC, &error_code, &error_message)); EXPECT_FALSE(root.get()); EXPECT_EQ(JSONReader::FormatErrorMessage(1, 7, JSONReader::kInvalidEscape), error_message); EXPECT_EQ(JSONReader::JSON_INVALID_ESCAPE, error_code); - root.reset(JSONReader::ReadAndReturnError("[\"xxx\\q\"]", false, + root.reset(JSONReader::ReadAndReturnError("[\"xxx\\q\"]", JSON_PARSE_RFC, &error_code, &error_message)); EXPECT_FALSE(root.get()); EXPECT_EQ(JSONReader::FormatErrorMessage(1, 7, JSONReader::kInvalidEscape), diff --git a/base/json/json_string_value_serializer.cc b/base/json/json_string_value_serializer.cc index 3045fa5..59c0765 100644 --- a/base/json/json_string_value_serializer.cc +++ b/base/json/json_string_value_serializer.cc @@ -40,7 +40,7 @@ Value* JSONStringValueSerializer::Deserialize(int* error_code, return NULL; return base::JSONReader::ReadAndReturnError(*json_string_, - allow_trailing_comma_, - error_code, - error_str); + allow_trailing_comma_ ? base::JSON_ALLOW_TRAILING_COMMAS : + base::JSON_PARSE_RFC, + error_code, error_str); } diff --git a/base/json/json_value_converter_unittest.cc b/base/json/json_value_converter_unittest.cc index b81a52c..46b06ed 100644 --- a/base/json/json_value_converter_unittest.cc +++ b/base/json/json_value_converter_unittest.cc @@ -79,7 +79,7 @@ TEST(JSONValueConverterTest, ParseSimpleMessage) { " \"ints\": [1, 2]" "}\n"; - scoped_ptr<Value> value(base::JSONReader::Read(normal_data, false)); + scoped_ptr<Value> value(base::JSONReader::Read(normal_data)); SimpleMessage message; base::JSONValueConverter<SimpleMessage> converter; EXPECT_TRUE(converter.Convert(*value.get(), &message)); @@ -114,7 +114,7 @@ TEST(JSONValueConverterTest, ParseNestedMessage) { " }]\n" "}\n"; - scoped_ptr<Value> value(base::JSONReader::Read(normal_data, false)); + scoped_ptr<Value> value(base::JSONReader::Read(normal_data)); NestedMessage message; base::JSONValueConverter<NestedMessage> converter; EXPECT_TRUE(converter.Convert(*value.get(), &message)); @@ -147,7 +147,7 @@ TEST(JSONValueConverterTest, ParseFailures) { " \"ints\": [1, 2]" "}\n"; - scoped_ptr<Value> value(base::JSONReader::Read(normal_data, false)); + scoped_ptr<Value> value(base::JSONReader::Read(normal_data)); SimpleMessage message; base::JSONValueConverter<SimpleMessage> converter; EXPECT_FALSE(converter.Convert(*value.get(), &message)); @@ -163,7 +163,7 @@ TEST(JSONValueConverterTest, ParseWithMissingFields) { " \"ints\": [1, 2]" "}\n"; - scoped_ptr<Value> value(base::JSONReader::Read(normal_data, false)); + scoped_ptr<Value> value(base::JSONReader::Read(normal_data)); SimpleMessage message; base::JSONValueConverter<SimpleMessage> converter; // Convert() still succeeds even if the input doesn't have "bar" field. @@ -186,7 +186,7 @@ TEST(JSONValueConverterTest, EnumParserFails) { " \"ints\": [1, 2]" "}\n"; - scoped_ptr<Value> value(base::JSONReader::Read(normal_data, false)); + scoped_ptr<Value> value(base::JSONReader::Read(normal_data)); SimpleMessage message; base::JSONValueConverter<SimpleMessage> converter; EXPECT_FALSE(converter.Convert(*value.get(), &message)); @@ -203,7 +203,7 @@ TEST(JSONValueConverterTest, RepeatedValueErrorInTheMiddle) { " \"ints\": [1, false]" "}\n"; - scoped_ptr<Value> value(base::JSONReader::Read(normal_data, false)); + scoped_ptr<Value> value(base::JSONReader::Read(normal_data)); SimpleMessage message; base::JSONValueConverter<SimpleMessage> converter; EXPECT_FALSE(converter.Convert(*value.get(), &message)); diff --git a/base/test/trace_event_analyzer.cc b/base/test/trace_event_analyzer.cc index ac4968c9..c0d9fae 100644 --- a/base/test/trace_event_analyzer.cc +++ b/base/test/trace_event_analyzer.cc @@ -644,7 +644,7 @@ size_t FindMatchingEvents(const std::vector<TraceEvent>& events, bool ParseEventsFromJson(const std::string& json, std::vector<TraceEvent>* output) { scoped_ptr<base::Value> root; - root.reset(base::JSONReader::Read(json, false)); + root.reset(base::JSONReader::Read(json)); ListValue* root_list = NULL; if (!root.get() || !root->GetAsList(&root_list)) diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 843be92..f870b73 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -2198,7 +2198,8 @@ void TestingAutomationProvider::SendJSONRequest(int handle, scoped_ptr<Value> values; base::JSONReader reader; std::string error; - values.reset(reader.ReadAndReturnError(json_request, true, NULL, &error)); + values.reset(reader.ReadAndReturnError(json_request, + base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error)); if (!error.empty()) { AutomationJSONReply(this, reply_message).SendError(error); return; diff --git a/chrome/browser/chrome_to_mobile_service.cc b/chrome/browser/chrome_to_mobile_service.cc index e4b07f6..840a014 100644 --- a/chrome/browser/chrome_to_mobile_service.cc +++ b/chrome/browser/chrome_to_mobile_service.cc @@ -425,7 +425,7 @@ void ChromeToMobileService::HandleAccountInfoResponse() { ListValue* services = NULL; DictionaryValue* dictionary = NULL; - scoped_ptr<Value> json(base::JSONReader::Read(data, false)); + scoped_ptr<Value> json(base::JSONReader::Read(data)); StringValue cloud_print_service(kCloudPrintSerivceValue); if (json.get() && json->GetAsDictionary(&dictionary) && dictionary && dictionary->GetList(kAccountServicesKey, &services) && services && @@ -444,7 +444,7 @@ void ChromeToMobileService::HandleSearchResponse() { ListValue* list = NULL; DictionaryValue* dictionary = NULL; - scoped_ptr<Value> json(base::JSONReader::Read(data, false)); + scoped_ptr<Value> json(base::JSONReader::Read(data)); if (json.get() && json->GetAsDictionary(&dictionary) && dictionary && dictionary->GetList(cloud_print::kPrinterListValue, &list)) { ScopedVector<base::DictionaryValue> mobiles; @@ -482,7 +482,7 @@ void ChromeToMobileService::HandleSubmitResponse( source->GetResponseAsString(&data); bool success = false; DictionaryValue* dictionary = NULL; - scoped_ptr<Value> json(base::JSONReader::Read(data, false)); + scoped_ptr<Value> json(base::JSONReader::Read(data)); if (json.get() && json->GetAsDictionary(&dictionary) && dictionary) dictionary->GetBoolean("success", &success); diff --git a/chrome/browser/chromeos/cros/network_parser.cc b/chrome/browser/chromeos/cros/network_parser.cc index 0bf606d..af41b12 100644 --- a/chrome/browser/chromeos/cros/network_parser.cc +++ b/chrome/browser/chromeos/cros/network_parser.cc @@ -217,7 +217,7 @@ bool NetworkParser::ParseValue(PropertyIndex index, if (!value.GetAsString(&ui_data_json)) return false; scoped_ptr<base::Value> ui_data_value( - base::JSONReader::Read(ui_data_json, false)); + base::JSONReader::Read(ui_data_json)); base::DictionaryValue* ui_data_dict = NULL; if (!ui_data_value.get() || !ui_data_value->GetAsDictionary(&ui_data_dict)) diff --git a/chrome/browser/chromeos/customization_document.cc b/chrome/browser/chromeos/customization_document.cc index f0434de..01bdb8e 100644 --- a/chrome/browser/chromeos/customization_document.cc +++ b/chrome/browser/chromeos/customization_document.cc @@ -92,9 +92,7 @@ bool CustomizationDocument::LoadManifestFromString( int error_code = 0; std::string error; scoped_ptr<Value> root(base::JSONReader::ReadAndReturnError(manifest, - true, - &error_code, - &error)); + base::JSON_ALLOW_TRAILING_COMMAS, &error_code, &error)); if (error_code != base::JSONReader::JSON_NO_ERROR) LOG(ERROR) << error; DCHECK(root.get() != NULL); diff --git a/chrome/browser/chromeos/extensions/file_manager_util.cc b/chrome/browser/chromeos/extensions/file_manager_util.cc index 4aed8df7..8b15ee4 100644 --- a/chrome/browser/chromeos/extensions/file_manager_util.cc +++ b/chrome/browser/chromeos/extensions/file_manager_util.cc @@ -527,8 +527,7 @@ void ReadUrlFromGDocOnFileThread(const FilePath& file_path) { } scoped_ptr<base::Value> root_value; - root_value.reset( - base::JSONReader::Read(contents, false /* no trailing comma */)); + root_value.reset(base::JSONReader::Read(contents)); DictionaryValue* dictionary_value; std::string edit_url_string; diff --git a/chrome/browser/chromeos/gdata/gdata_documents_service_browsertest.cc b/chrome/browser/chromeos/gdata/gdata_documents_service_browsertest.cc index 1694258..95da95c 100644 --- a/chrome/browser/chromeos/gdata/gdata_documents_service_browsertest.cc +++ b/chrome/browser/chromeos/gdata/gdata_documents_service_browsertest.cc @@ -118,7 +118,7 @@ IN_PROC_BROWSER_TEST_F(GDataTest, GetDocuments) { std::string expected_contents; file_util::ReadFileToString(expected_filepath, &expected_contents); scoped_ptr<base::Value> expected_data( - base::JSONReader::Read(expected_contents, false)); + base::JSONReader::Read(expected_contents)); EXPECT_TRUE(base::Value::Equals(expected_data.get(), result_data)); delete result_data; } diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc index a06a7a2..c997c2c 100644 --- a/chrome/browser/chromeos/gdata/gdata_file_system.cc +++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc @@ -2237,7 +2237,8 @@ void GDataFileSystem::LoadJsonFileOnIOThreadPool( int unused_error_code = -1; std::string unused_error_message; root_value.reset(base::JSONReader::ReadAndReturnError( - contents, false, &unused_error_code, &unused_error_message)); + contents, base::JSON_PARSE_RFC, &unused_error_code, + &unused_error_message)); bool has_root = root_value.get(); if (!has_root) diff --git a/chrome/browser/chromeos/gdata/gdata_operations.cc b/chrome/browser/chromeos/gdata/gdata_operations.cc index 4aeda4c..4f4b394 100644 --- a/chrome/browser/chromeos/gdata/gdata_operations.cc +++ b/chrome/browser/chromeos/gdata/gdata_operations.cc @@ -427,7 +427,7 @@ base::Value* GetDataOperation::ParseResponse(const std::string& data) { int error_code = -1; std::string error_message; scoped_ptr<base::Value> root_value(base::JSONReader::ReadAndReturnError( - data, false, &error_code, &error_message)); + data, base::JSON_PARSE_RFC, &error_code, &error_message)); if (!root_value.get()) { LOG(ERROR) << "Error while parsing entry response: " << error_message diff --git a/chrome/browser/chromeos/gdata/gdata_util.cc b/chrome/browser/chromeos/gdata/gdata_util.cc index d9304ac..a4adaa5 100644 --- a/chrome/browser/chromeos/gdata/gdata_util.cc +++ b/chrome/browser/chromeos/gdata/gdata_util.cc @@ -81,7 +81,7 @@ void GetHostedDocumentURLBlockingThread(const FilePath& gdata_cache_path, return; } DVLOG(1) << "Hosted doc content " << json; - scoped_ptr<base::Value> val(base::JSONReader::Read(json, false)); + scoped_ptr<base::Value> val(base::JSONReader::Read(json)); base::DictionaryValue* dict_val; if (!val.get() || !val->GetAsDictionary(&dict_val)) { NOTREACHED() << "Parse failure for " << json; diff --git a/chrome/browser/content_settings/content_settings_policy_provider.cc b/chrome/browser/content_settings/content_settings_policy_provider.cc index 85a0631..f71bb4ca 100644 --- a/chrome/browser/content_settings/content_settings_policy_provider.cc +++ b/chrome/browser/content_settings/content_settings_policy_provider.cc @@ -303,8 +303,8 @@ void PolicyProvider::GetAutoSelectCertificateSettingsFromPreferences( continue; } - scoped_ptr<base::Value> value( - base::JSONReader::Read(pattern_filter_json, true)); + scoped_ptr<base::Value> value(base::JSONReader::Read(pattern_filter_json, + base::JSON_ALLOW_TRAILING_COMMAS)); if (!value.get()) { VLOG(1) << "Ignoring invalid certificate auto select setting. Reason:" " Invalid JSON format: " << pattern_filter_json; diff --git a/chrome/browser/content_settings/host_content_settings_map_unittest.cc b/chrome/browser/content_settings/host_content_settings_map_unittest.cc index f59e588..73aee59 100644 --- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc +++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc @@ -727,12 +727,12 @@ TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeAndPunycode) { TestingProfile profile; scoped_ptr<Value> value(base::JSONReader::Read( - "{\"[*.]\\xC4\\x87ira.com,*\":{\"images\":1}}", false)); + "{\"[*.]\\xC4\\x87ira.com,*\":{\"images\":1}}")); profile.GetPrefs()->Set(prefs::kContentSettingsPatternPairs, *value); // Set punycode equivalent, with different setting. scoped_ptr<Value> puny_value(base::JSONReader::Read( - "{\"[*.]xn--ira-ppa.com,*\":{\"images\":2}}", false)); + "{\"[*.]xn--ira-ppa.com,*\":{\"images\":2}}")); profile.GetPrefs()->Set(prefs::kContentSettingsPatternPairs, *puny_value); // Initialize the content map. @@ -799,7 +799,7 @@ TEST_F(HostContentSettingsMapTest, ResourceIdentifierPrefs) { TestingProfile profile; scoped_ptr<Value> value(base::JSONReader::Read( - "{\"[*.]example.com,*\":{\"per_plugin\":{\"someplugin\":2}}}", false)); + "{\"[*.]example.com,*\":{\"per_plugin\":{\"someplugin\":2}}}")); profile.GetPrefs()->Set(prefs::kContentSettingsPatternPairs, *value); HostContentSettingsMap* host_content_settings_map = profile.GetHostContentSettingsMap(); diff --git a/chrome/browser/extensions/app_notification_storage.cc b/chrome/browser/extensions/app_notification_storage.cc index 914f997..42f11b2 100644 --- a/chrome/browser/extensions/app_notification_storage.cc +++ b/chrome/browser/extensions/app_notification_storage.cc @@ -80,8 +80,7 @@ void AppNotificationListToJSON(const AppNotificationList& list, bool JSONToAppNotificationList(const std::string& json, AppNotificationList* list) { CHECK(list); - scoped_ptr<Value> value(JSONReader::Read(json, - false /* allow_trailing_comma */)); + scoped_ptr<Value> value(JSONReader::Read(json)); if (!value.get() || value->GetType() != Value::TYPE_LIST) return false; diff --git a/chrome/browser/extensions/app_notify_channel_setup.cc b/chrome/browser/extensions/app_notify_channel_setup.cc index f3200ba..bdce1d5 100644 --- a/chrome/browser/extensions/app_notify_channel_setup.cc +++ b/chrome/browser/extensions/app_notify_channel_setup.cc @@ -402,8 +402,7 @@ std::string AppNotifyChannelSetup::MakeAuthorizationHeader( // static bool AppNotifyChannelSetup::ParseCWSChannelServiceResponse( const std::string& data, std::string* result) { - base::JSONReader reader; - scoped_ptr<base::Value> value(reader.Read(data, false)); + scoped_ptr<base::Value> value(base::JSONReader::Read(data)); if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) return false; diff --git a/chrome/browser/extensions/chrome_app_api_browsertest.cc b/chrome/browser/extensions/chrome_app_api_browsertest.cc index 7335306..44e91cc 100644 --- a/chrome/browser/extensions/chrome_app_api_browsertest.cc +++ b/chrome/browser/extensions/chrome_app_api_browsertest.cc @@ -97,8 +97,7 @@ IN_PROC_BROWSER_TEST_F(ChromeAppAPITest, IsInstalled) { browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", get_app_details, &result)); scoped_ptr<DictionaryValue> app_details( - static_cast<DictionaryValue*>( - base::JSONReader::Read(result, false /* allow trailing comma */))); + static_cast<DictionaryValue*>(base::JSONReader::Read(result))); // extension->manifest() does not contain the id. app_details->Remove("id", NULL); EXPECT_TRUE(app_details.get()); @@ -176,8 +175,7 @@ IN_PROC_BROWSER_TEST_F(ChromeAppAPITest, GetDetailsForFrame) { L"", get_details_for_frame, &json)); scoped_ptr<DictionaryValue> app_details( - static_cast<DictionaryValue*>( - base::JSONReader::Read(json, false /* allow trailing comma */))); + static_cast<DictionaryValue*>(base::JSONReader::Read(json))); // extension->manifest() does not contain the id. app_details->Remove("id", NULL); EXPECT_TRUE(app_details.get()); diff --git a/chrome/browser/extensions/extension_debugger_api.cc b/chrome/browser/extensions/extension_debugger_api.cc index 5bf283b..646eb0f 100644 --- a/chrome/browser/extensions/extension_debugger_api.cc +++ b/chrome/browser/extensions/extension_debugger_api.cc @@ -283,7 +283,7 @@ void ExtensionDevToolsClientHost::DispatchOnInspectorFrontend( if (profile == NULL || !profile->GetExtensionEventRouter()) return; - scoped_ptr<Value> result(base::JSONReader::Read(message, false)); + scoped_ptr<Value> result(base::JSONReader::Read(message)); if (!result->IsType(Value::TYPE_DICTIONARY)) return; DictionaryValue* dictionary = static_cast<DictionaryValue*>(result.get()); diff --git a/chrome/browser/extensions/extension_function_test_utils.cc b/chrome/browser/extensions/extension_function_test_utils.cc index 889f6be..35989dc 100644 --- a/chrome/browser/extensions/extension_function_test_utils.cc +++ b/chrome/browser/extensions/extension_function_test_utils.cc @@ -44,8 +44,7 @@ class TestFunctionDispatcherDelegate namespace extension_function_test_utils { base::Value* ParseJSON(const std::string& data) { - const bool kAllowTrailingComma = false; - return base::JSONReader::Read(data, kAllowTrailingComma); + return base::JSONReader::Read(data); } base::ListValue* ParseList(const std::string& data) { diff --git a/chrome/browser/extensions/extension_menu_manager_unittest.cc b/chrome/browser/extensions/extension_menu_manager_unittest.cc index 7fc9ff3..cae9a9b 100644 --- a/chrome/browser/extensions/extension_menu_manager_unittest.cc +++ b/chrome/browser/extensions/extension_menu_manager_unittest.cc @@ -467,7 +467,8 @@ TEST_F(ExtensionMenuManagerTest, ExecuteCommand) { // Parse the json event_args, which should turn into a 2-element list where // the first element is a dictionary we want to inspect for the correct // values. - scoped_ptr<Value> result(base::JSONReader::Read(event_args, true)); + scoped_ptr<Value> result( + base::JSONReader::Read(event_args, base::JSON_ALLOW_TRAILING_COMMAS)); Value* value = result.get(); ASSERT_TRUE(result.get() != NULL); ASSERT_EQ(Value::TYPE_LIST, value->GetType()); diff --git a/chrome/browser/extensions/settings/setting_sync_data.cc b/chrome/browser/extensions/settings/setting_sync_data.cc index 6f0cd08..4f54052 100644 --- a/chrome/browser/extensions/settings/setting_sync_data.cc +++ b/chrome/browser/extensions/settings/setting_sync_data.cc @@ -46,7 +46,7 @@ void SettingSyncData::InitFromExtensionSettingSpecifics( const sync_pb::ExtensionSettingSpecifics& specifics) { DCHECK(!internal_.get()); scoped_ptr<Value> value( - base::JSONReader().JsonToValue(specifics.value(), false, false)); + base::JSONReader::Read(specifics.value())); if (!value.get()) { LOG(WARNING) << "Specifics for " << specifics.extension_id() << "/" << specifics.key() << " had bad JSON for value: " << specifics.value(); diff --git a/chrome/browser/gpu_blacklist.cc b/chrome/browser/gpu_blacklist.cc index 79c41b9..24bb9da 100644 --- a/chrome/browser/gpu_blacklist.cc +++ b/chrome/browser/gpu_blacklist.cc @@ -769,7 +769,7 @@ bool GpuBlacklist::LoadGpuBlacklist( DCHECK(browser_version_.get() != NULL); scoped_ptr<Value> root; - root.reset(base::JSONReader::Read(json_context, false)); + root.reset(base::JSONReader::Read(json_context)); if (root.get() == NULL || !root->IsType(Value::TYPE_DICTIONARY)) return false; diff --git a/chrome/browser/net/gaia/gaia_oauth_fetcher.cc b/chrome/browser/net/gaia/gaia_oauth_fetcher.cc index 4ee520b..2d12697 100644 --- a/chrome/browser/net/gaia/gaia_oauth_fetcher.cc +++ b/chrome/browser/net/gaia/gaia_oauth_fetcher.cc @@ -264,8 +264,7 @@ void GaiaOAuthFetcher::ParseOAuthWrapBridgeResponse(const std::string& data, // static void GaiaOAuthFetcher::ParseUserInfoResponse(const std::string& data, std::string* email_result) { - base::JSONReader reader; - scoped_ptr<base::Value> value(reader.Read(data, false)); + scoped_ptr<base::Value> value(base::JSONReader::Read(data)); if (value->GetType() == base::Value::TYPE_DICTIONARY) { Value* email_value; DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); diff --git a/chrome/browser/plugin_finder.cc b/chrome/browser/plugin_finder.cc index 2b66754..a0eaf03 100644 --- a/chrome/browser/plugin_finder.cc +++ b/chrome/browser/plugin_finder.cc @@ -51,11 +51,10 @@ DictionaryValue* PluginFinder::LoadPluginListInternal() { base::StringPiece json_resource( ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_PLUGIN_DB_JSON)); - bool allow_trailing_comma = false; std::string error_str; scoped_ptr<base::Value> value(base::JSONReader::ReadAndReturnError( json_resource.as_string(), - allow_trailing_comma, + base::JSON_PARSE_RFC, NULL, &error_str)); if (!value.get()) { diff --git a/chrome/browser/policy/configuration_policy_handler_chromeos.cc b/chrome/browser/policy/configuration_policy_handler_chromeos.cc index ff43551..2ad2655 100644 --- a/chrome/browser/policy/configuration_policy_handler_chromeos.cc +++ b/chrome/browser/policy/configuration_policy_handler_chromeos.cc @@ -74,7 +74,8 @@ Value* NetworkConfigurationPolicyHandler::SanitizeNetworkConfig( if (!config->GetAsString(&json_string)) return NULL; - scoped_ptr<Value> json_value(base::JSONReader::Read(json_string, true)); + scoped_ptr<Value> json_value( + base::JSONReader::Read(json_string, base::JSON_ALLOW_TRAILING_COMMAS)); if (!json_value.get() || !json_value->IsType(base::Value::TYPE_DICTIONARY)) return NULL; diff --git a/chrome/browser/printing/cloud_print/cloud_print_setup_message_handler.cc b/chrome/browser/printing/cloud_print/cloud_print_setup_message_handler.cc index 27bd893..fb34458 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_setup_message_handler.cc +++ b/chrome/browser/printing/cloud_print/cloud_print_setup_message_handler.cc @@ -36,7 +36,7 @@ void CloudPrintSetupMessageHandler::HandleSubmitAuth(const ListValue* args) { return; } - scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); + scoped_ptr<Value> parsed_value(base::JSONReader::Read(json)); if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY)) { NOTREACHED() << "Unable to parse auth data"; return; diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc index 42a711d..c495bac 100644 --- a/chrome/browser/printing/print_dialog_cloud.cc +++ b/chrome/browser/printing/print_dialog_cloud.cc @@ -130,7 +130,7 @@ namespace internal_cloud_print_helpers { // parameters. bool GetPageSetupParameters(const std::string& json, PrintMsg_Print_Params& parameters) { - scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); + scoped_ptr<Value> parsed_value(base::JSONReader::Read(json)); DLOG_IF(ERROR, (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY))) << "PageSetup call didn't have expected contents"; diff --git a/chrome/browser/profiles/profile_downloader.cc b/chrome/browser/profiles/profile_downloader.cc index 40a0a42..179a3ce 100644 --- a/chrome/browser/profiles/profile_downloader.cc +++ b/chrome/browser/profiles/profile_downloader.cc @@ -139,7 +139,7 @@ bool ProfileDownloader::GetProfileNameAndImageURL(const std::string& data, int error_code = -1; std::string error_message; scoped_ptr<base::Value> root_value(base::JSONReader::ReadAndReturnError( - data, false, &error_code, &error_message)); + data, base::JSON_PARSE_RFC, &error_code, &error_message)); if (!root_value.get()) { LOG(ERROR) << "Error while parsing user entry response: " << error_message; diff --git a/chrome/browser/spellchecker/spelling_service_client.cc b/chrome/browser/spellchecker/spelling_service_client.cc index 85bbc47..1b406dd 100644 --- a/chrome/browser/spellchecker/spelling_service_client.cc +++ b/chrome/browser/spellchecker/spelling_service_client.cc @@ -153,7 +153,8 @@ bool SpellingServiceClient::ParseResponse( // } // } scoped_ptr<DictionaryValue> value( - static_cast<DictionaryValue*>(base::JSONReader::Read(data, true))); + static_cast<DictionaryValue*>( + base::JSONReader::Read(data, base::JSON_ALLOW_TRAILING_COMMAS))); if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) return false; diff --git a/chrome/browser/sync/notifier/p2p_notifier.cc b/chrome/browser/sync/notifier/p2p_notifier.cc index e9b4ef20..ee3a4da6 100644 --- a/chrome/browser/sync/notifier/p2p_notifier.cc +++ b/chrome/browser/sync/notifier/p2p_notifier.cc @@ -109,8 +109,7 @@ std::string P2PNotificationData::ToString() const { } bool P2PNotificationData::ResetFromString(const std::string& str) { - scoped_ptr<Value> data_value( - base::JSONReader::Read(str, false /* allow_trailing_comma */)); + scoped_ptr<Value> data_value(base::JSONReader::Read(str)); if (!data_value.get()) { LOG(WARNING) << "Could not parse " << str; return false; diff --git a/chrome/browser/sync/profile_sync_service_preference_unittest.cc b/chrome/browser/sync/profile_sync_service_preference_unittest.cc index b22406a..da17a86 100644 --- a/chrome/browser/sync/profile_sync_service_preference_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_preference_unittest.cc @@ -164,8 +164,7 @@ class ProfileSyncServicePreferenceTest const sync_pb::PreferenceSpecifics& specifics( node.GetEntitySpecifics().preference()); - JSONReader reader; - return reader.JsonToValue(specifics.value(), false, false); + return base::JSONReader::Read(specifics.value()); } int64 WriteSyncedValue(const std::string& name, @@ -255,8 +254,7 @@ TEST_F(ProfileSyncServicePreferenceTest, CreatePrefSyncData) { preference()); EXPECT_EQ(std::string(prefs::kHomePage), specifics.name()); - base::JSONReader reader; - scoped_ptr<Value> value(reader.JsonToValue(specifics.value(), false, false)); + scoped_ptr<Value> value(base::JSONReader::Read(specifics.value())); EXPECT_TRUE(pref->GetValue()->Equals(value.get())); } diff --git a/chrome/browser/themes/browser_theme_pack_unittest.cc b/chrome/browser/themes/browser_theme_pack_unittest.cc index c13c72f..bcf81ef 100644 --- a/chrome/browser/themes/browser_theme_pack_unittest.cc +++ b/chrome/browser/themes/browser_theme_pack_unittest.cc @@ -79,7 +79,7 @@ class BrowserThemePackTest : public ::testing::Test { } void LoadColorJSON(const std::string& json) { - scoped_ptr<Value> value(base::JSONReader::Read(json, false)); + scoped_ptr<Value> value(base::JSONReader::Read(json)); ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); LoadColorDictionary(static_cast<DictionaryValue*>(value.get())); } @@ -89,7 +89,7 @@ class BrowserThemePackTest : public ::testing::Test { } void LoadTintJSON(const std::string& json) { - scoped_ptr<Value> value(base::JSONReader::Read(json, false)); + scoped_ptr<Value> value(base::JSONReader::Read(json)); ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); LoadTintDictionary(static_cast<DictionaryValue*>(value.get())); } @@ -99,7 +99,7 @@ class BrowserThemePackTest : public ::testing::Test { } void LoadDisplayPropertiesJSON(const std::string& json) { - scoped_ptr<Value> value(base::JSONReader::Read(json, false)); + scoped_ptr<Value> value(base::JSONReader::Read(json)); ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); LoadDisplayPropertiesDictionary(static_cast<DictionaryValue*>(value.get())); } @@ -110,7 +110,7 @@ class BrowserThemePackTest : public ::testing::Test { void ParseImageNamesJSON(const std::string& json, std::map<int, FilePath>* out_file_paths) { - scoped_ptr<Value> value(base::JSONReader::Read(json, false)); + scoped_ptr<Value> value(base::JSONReader::Read(json)); ASSERT_TRUE(value->IsType(Value::TYPE_DICTIONARY)); ParseImageNamesDictionary(static_cast<DictionaryValue*>(value.get()), out_file_paths); diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index 4158484..f5076f0 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -220,7 +220,8 @@ void TranslateManager::SetSupportedLanguages(const std::string& language_list) { // JSON doesn't support single quotes though this is what is used on the // translate server so we must replace them with double quotes. ReplaceSubstringsAfterOffset(&languages_json, 0, "'", "\""); - scoped_ptr<Value> json_value(base::JSONReader::Read(languages_json, true)); + scoped_ptr<Value> json_value( + base::JSONReader::Read(languages_json, base::JSON_ALLOW_TRAILING_COMMAS)); if (json_value == NULL || !json_value->IsType(Value::TYPE_DICTIONARY)) { NOTREACHED(); return; diff --git a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc index 08710f2..cc8ca0e 100644 --- a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc +++ b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc @@ -394,7 +394,8 @@ bool CellularConfigDocument::LoadFromFile(const FilePath& config_path) { if (!file_util::ReadFileToString(config_path, &config)) return false; - scoped_ptr<Value> root(base::JSONReader::Read(config, true)); + scoped_ptr<Value> root( + base::JSONReader::Read(config, base::JSON_ALLOW_TRAILING_COMMAS)); DCHECK(root.get() != NULL); if (!root.get() || root->GetType() != Value::TYPE_DICTIONARY) { LOG(WARNING) << "Bad cellular config file"; diff --git a/chrome/browser/ui/webui/options2/core_options_handler2.cc b/chrome/browser/ui/webui/options2/core_options_handler2.cc index 226756b..d25a3f1 100644 --- a/chrome/browser/ui/webui/options2/core_options_handler2.cc +++ b/chrome/browser/ui/webui/options2/core_options_handler2.cc @@ -416,9 +416,7 @@ void CoreOptionsHandler::HandleSetPref(const ListValue* args, PrefType type) { std::string json_string; CHECK(value->GetAsString(&json_string)); temp_value.reset( - base::JSONReader().JsonToValue(json_string, - false, // no check_root - false)); // no trailing comma + base::JSONReader::Read(json_string)); value = temp_value.get(); CHECK_EQ(base::Value::TYPE_LIST, value->GetType()); break; diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc index a8f1b09..016c425 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc @@ -132,7 +132,7 @@ DictionaryValue* GetSettingsDictionary(const ListValue* args) { return NULL; } scoped_ptr<DictionaryValue> settings(static_cast<DictionaryValue*>( - base::JSONReader::Read(json_str, false))); + base::JSONReader::Read(json_str))); if (!settings.get() || !settings->IsType(Value::TYPE_DICTIONARY)) { NOTREACHED() << "Print job settings must be a dictionary."; return NULL; diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc index 7ce131f..78ea499 100644 --- a/chrome/browser/ui/webui/sync_setup_handler.cc +++ b/chrome/browser/ui/webui/sync_setup_handler.cc @@ -95,7 +95,7 @@ bool GetAuthData(const std::string& json, std::string* password, std::string* captcha, std::string* access_code) { - scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); + scoped_ptr<Value> parsed_value(base::JSONReader::Read(json)); if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY)) return false; @@ -110,7 +110,7 @@ bool GetAuthData(const std::string& json, } bool GetConfiguration(const std::string& json, SyncConfigInfo* config) { - scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); + scoped_ptr<Value> parsed_value(base::JSONReader::Read(json)); DictionaryValue* result; if (!parsed_value.get() || !parsed_value->GetAsDictionary(&result)) { DLOG(ERROR) << "GetConfiguration() not passed a Dictionary"; @@ -161,7 +161,7 @@ bool GetConfiguration(const std::string& json, SyncConfigInfo* config) { } bool GetPassphrase(const std::string& json, std::string* passphrase) { - scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); + scoped_ptr<Value> parsed_value(base::JSONReader::Read(json)); if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY)) return false; @@ -720,7 +720,7 @@ void SyncSetupHandler::HandleAttachHandler(const ListValue* args) { bool force_login = false; std::string json; if (args->GetString(0, &json) && !json.empty()) { - scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); + scoped_ptr<Value> parsed_value(base::JSONReader::Read(json)); DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get()); result->GetBoolean("forceLogin", &force_login); } diff --git a/chrome/browser/web_resource/promo_resource_service_unittest.cc b/chrome/browser/web_resource/promo_resource_service_unittest.cc index 017fb85..ee50587 100644 --- a/chrome/browser/web_resource/promo_resource_service_unittest.cc +++ b/chrome/browser/web_resource/promo_resource_service_unittest.cc @@ -57,7 +57,7 @@ TEST_F(PromoResourceServiceTest, UnpackLogoSignal) { " }" "}"; scoped_ptr<DictionaryValue> test_json( - static_cast<DictionaryValue*>(base::JSONReader::Read(json, false))); + static_cast<DictionaryValue*>(base::JSONReader::Read(json))); // Check that prefs are set correctly. web_resource_service_->UnpackLogoSignal(*(test_json.get())); @@ -88,7 +88,7 @@ TEST_F(PromoResourceServiceTest, UnpackLogoSignal) { "}"; test_json->Clear(); test_json.reset(static_cast<DictionaryValue*>( - base::JSONReader::Read(json, false))); + base::JSONReader::Read(json))); // Check that prefs are set correctly. web_resource_service_->UnpackLogoSignal(*(test_json.get())); @@ -107,7 +107,7 @@ TEST_F(PromoResourceServiceTest, UnpackLogoSignal) { "}"; test_json->Clear(); test_json.reset(static_cast<DictionaryValue*>( - base::JSONReader::Read(json, false))); + base::JSONReader::Read(json))); // Check that prefs are set correctly. web_resource_service_->UnpackLogoSignal(*(test_json.get())); @@ -150,7 +150,7 @@ class NotificationPromoTestDelegate : public NotificationPromo::Delegate { notification_promo_ = notification_promo; test_json_.reset(static_cast<DictionaryValue*>( - base::JSONReader::Read(json, false))); + base::JSONReader::Read(json))); start_ = start; end_ = end; @@ -696,7 +696,7 @@ TEST_F(PromoResourceServiceTest, UnpackWebStoreSignal) { " }" "}"; scoped_ptr<DictionaryValue> test_json(static_cast<DictionaryValue*>( - base::JSONReader::Read(json, false))); + base::JSONReader::Read(json))); // Set the source logo URL to verify that it gets cleared. AppsPromo::SetSourcePromoLogoURL(GURL("https://www.google.com/test.png")); @@ -732,7 +732,7 @@ TEST_F(PromoResourceServiceTest, UnpackPartialWebStoreSignal) { " }" "}"; scoped_ptr<DictionaryValue> test_json(static_cast<DictionaryValue*>( - base::JSONReader::Read(json, false))); + base::JSONReader::Read(json))); // Check that prefs are set correctly. web_resource_service_->UnpackWebStoreSignal(*(test_json.get())); @@ -769,7 +769,7 @@ TEST_F(PromoResourceServiceTest, UnpackWebStoreSignalHttpsLogo) { "}"; scoped_ptr<DictionaryValue> test_json(static_cast<DictionaryValue*>( - base::JSONReader::Read(json, false))); + base::JSONReader::Read(json))); // Update the promo multiple times to verify the logo is cached correctly. for (size_t i = 0; i < 2; ++i) { @@ -829,7 +829,7 @@ TEST_F(PromoResourceServiceTest, UnpackWebStoreSignalHttpsLogoError) { "}"; scoped_ptr<DictionaryValue> test_json(static_cast<DictionaryValue*>( - base::JSONReader::Read(json, false))); + base::JSONReader::Read(json))); web_resource_service_->UnpackWebStoreSignal(*(test_json.get())); @@ -880,7 +880,7 @@ TEST_F(PromoResourceServiceTest, UnpackWebStoreSignalHttpLogo) { "}"; scoped_ptr<DictionaryValue> test_json(static_cast<DictionaryValue*>( - base::JSONReader::Read(json, false))); + base::JSONReader::Read(json))); web_resource_service_->UnpackWebStoreSignal(*(test_json.get())); diff --git a/chrome/common/cloud_print/cloud_print_helpers.cc b/chrome/common/cloud_print/cloud_print_helpers.cc index cebe4a3..e8f7650 100644 --- a/chrome/common/cloud_print/cloud_print_helpers.cc +++ b/chrome/common/cloud_print/cloud_print_helpers.cc @@ -47,7 +47,7 @@ GURL GetUrlForSubmit(const GURL& cloud_print_server_url) { bool ParseResponseJSON(const std::string& response_data, bool* succeeded, DictionaryValue** response_dict) { - scoped_ptr<Value> message_value(base::JSONReader::Read(response_data, false)); + scoped_ptr<Value> message_value(base::JSONReader::Read(response_data)); if (!message_value.get()) return false; diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc index 44e3951..0b94a3c 100644 --- a/chrome/common/extensions/api/extension_api.cc +++ b/chrome/common/extensions/api/extension_api.cc @@ -68,7 +68,7 @@ scoped_ptr<ListValue> LoadSchemaList(const base::StringPiece& schema) { scoped_ptr<Value> result( base::JSONReader::ReadAndReturnError( schema.as_string(), - false, // allow trailing commas + base::JSON_PARSE_RFC, // options NULL, // error code &error_message)); CHECK(result.get()) << error_message; diff --git a/chrome/common/extensions/simple_feature_provider.cc b/chrome/common/extensions/simple_feature_provider.cc index 63741aa..08bed31 100644 --- a/chrome/common/extensions/simple_feature_provider.cc +++ b/chrome/common/extensions/simple_feature_provider.cc @@ -15,8 +15,6 @@ namespace extensions { namespace { -const bool kAllowTrailingComma = false; - template<class FeatureClass> Feature* CreateFeature() { return new FeatureClass(); @@ -48,7 +46,8 @@ struct Static { int error_code = 0; std::string error_message; Value* value = base::JSONReader::ReadAndReturnError( - manifest_features, kAllowTrailingComma, &error_code, &error_message); + manifest_features, base::JSON_PARSE_RFC, + &error_code, &error_message); CHECK(value) << "Could not load features: " << debug_string << " " << error_message; CHECK(value->IsType(Value::TYPE_DICTIONARY)) << debug_string; diff --git a/chrome/common/json_value_serializer_unittest.cc b/chrome/common/json_value_serializer_unittest.cc index a7b0c37..11982ec 100644 --- a/chrome/common/json_value_serializer_unittest.cc +++ b/chrome/common/json_value_serializer_unittest.cc @@ -195,7 +195,7 @@ TEST(JSONValueSerializerTest, AllowTrailingComma) { namespace { void ValidateJsonList(const std::string& json) { - scoped_ptr<Value> root(base::JSONReader::Read(json, false)); + scoped_ptr<Value> root(base::JSONReader::Read(json)); ASSERT_TRUE(root.get() && root->IsType(Value::TYPE_LIST)); ListValue* list = static_cast<ListValue*>(root.get()); ASSERT_EQ(1U, list->GetSize()); @@ -219,7 +219,7 @@ TEST(JSONValueSerializerTest, JSONReaderComments) { scoped_ptr<Value> root; // It's ok to have a comment in a string. - root.reset(base::JSONReader::Read("[\"// ok\\n /* foo */ \"]", false)); + root.reset(base::JSONReader::Read("[\"// ok\\n /* foo */ \"]")); ASSERT_TRUE(root.get() && root->IsType(Value::TYPE_LIST)); ListValue* list = static_cast<ListValue*>(root.get()); ASSERT_EQ(1U, list->GetSize()); @@ -230,11 +230,11 @@ TEST(JSONValueSerializerTest, JSONReaderComments) { ASSERT_EQ("// ok\n /* foo */ ", value); // You can't nest comments. - root.reset(base::JSONReader::Read("/* /* inner */ outer */ [ 1 ]", false)); + root.reset(base::JSONReader::Read("/* /* inner */ outer */ [ 1 ]")); ASSERT_FALSE(root.get()); // Not a open comment token. - root.reset(base::JSONReader::Read("/ * * / [1]", false)); + root.reset(base::JSONReader::Read("/ * * / [1]")); ASSERT_FALSE(root.get()); } diff --git a/chrome/common/net/gaia/gaia_auth_fetcher.cc b/chrome/common/net/gaia/gaia_auth_fetcher.cc index 002c0a6..cb759ad 100644 --- a/chrome/common/net/gaia/gaia_auth_fetcher.cc +++ b/chrome/common/net/gaia/gaia_auth_fetcher.cc @@ -407,8 +407,7 @@ bool GaiaAuthFetcher::ParseOAuth2TokenPairResponse(const std::string& data, int* expires_in_secs) { DCHECK(refresh_token); DCHECK(access_token); - base::JSONReader reader; - scoped_ptr<base::Value> value(reader.Read(data, false)); + scoped_ptr<base::Value> value(base::JSONReader::Read(data)); if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) return false; diff --git a/chrome/common/net/gaia/gaia_oauth_client.cc b/chrome/common/net/gaia/gaia_oauth_client.cc index f5fac42..eb4179d 100644 --- a/chrome/common/net/gaia/gaia_oauth_client.cc +++ b/chrome/common/net/gaia/gaia_oauth_client.cc @@ -144,7 +144,7 @@ void GaiaOAuthClient::Core::HandleResponse( if (source->GetResponseCode() == net::HTTP_OK) { std::string data; source->GetResponseAsString(&data); - scoped_ptr<Value> message_value(base::JSONReader::Read(data, false)); + scoped_ptr<Value> message_value(base::JSONReader::Read(data)); if (message_value.get() && message_value->IsType(Value::TYPE_DICTIONARY)) { scoped_ptr<DictionaryValue> response_dict( diff --git a/chrome/common/net/gaia/oauth2_access_token_fetcher.cc b/chrome/common/net/gaia/oauth2_access_token_fetcher.cc index 2523ba8..43db4a7 100644 --- a/chrome/common/net/gaia/oauth2_access_token_fetcher.cc +++ b/chrome/common/net/gaia/oauth2_access_token_fetcher.cc @@ -205,8 +205,7 @@ bool OAuth2AccessTokenFetcher::ParseGetAccessTokenResponse( CHECK(access_token); std::string data; source->GetResponseAsString(&data); - base::JSONReader reader; - scoped_ptr<base::Value> value(reader.Read(data, false)); + scoped_ptr<base::Value> value(base::JSONReader::Read(data)); if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) return false; diff --git a/chrome/common/net/gaia/oauth2_mint_token_fetcher.cc b/chrome/common/net/gaia/oauth2_mint_token_fetcher.cc index 84d2e0a..e573872 100644 --- a/chrome/common/net/gaia/oauth2_mint_token_fetcher.cc +++ b/chrome/common/net/gaia/oauth2_mint_token_fetcher.cc @@ -180,8 +180,7 @@ bool OAuth2MintTokenFetcher::ParseMintTokenResponse( CHECK(access_token); std::string data; source->GetResponseAsString(&data); - base::JSONReader reader; - scoped_ptr<base::Value> value(reader.Read(data, false)); + scoped_ptr<base::Value> value(base::JSONReader::Read(data)); if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) return false; diff --git a/chrome/common/web_apps.cc b/chrome/common/web_apps.cc index 5748f21..bfcf199 100644 --- a/chrome/common/web_apps.cc +++ b/chrome/common/web_apps.cc @@ -217,7 +217,7 @@ bool ParseWebAppFromDefinitionFile(Value* definition_value, base::JSONReader::ReadAndReturnError( ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_WEB_APP_SCHEMA).as_string(), - false, // disallow trailing comma + base::JSON_PARSE_RFC, // options &error_code, &error_message)); DCHECK(schema.get()) diff --git a/chrome/common/web_resource/web_resource_unpacker.cc b/chrome/common/web_resource/web_resource_unpacker.cc index e93ea36..34ed510 100644 --- a/chrome/common/web_resource/web_resource_unpacker.cc +++ b/chrome/common/web_resource/web_resource_unpacker.cc @@ -26,7 +26,7 @@ WebResourceUnpacker::~WebResourceUnpacker() { bool WebResourceUnpacker::Run() { scoped_ptr<Value> value; if (!resource_data_.empty()) { - value.reset(base::JSONReader::Read(resource_data_, false)); + value.reset(base::JSONReader::Read(resource_data_)); if (!value.get()) { // Page information not properly read, or corrupted. error_message_ = kInvalidDataTypeError; diff --git a/chrome/renderer/extensions/send_request_natives.cc b/chrome/renderer/extensions/send_request_natives.cc index f493828..e5377ce 100644 --- a/chrome/renderer/extensions/send_request_natives.cc +++ b/chrome/renderer/extensions/send_request_natives.cc @@ -33,9 +33,7 @@ v8::Handle<v8::Value> SendRequestNatives::GetNextRequestId( v8::Handle<v8::Value> SendRequestNatives::StartRequest( const v8::Arguments& args) { std::string str_args = *v8::String::Utf8Value(args[1]); - base::JSONReader reader; - scoped_ptr<Value> value_args; - value_args.reset(reader.JsonToValue(str_args, false, false)); + scoped_ptr<Value> value_args(base::JSONReader::Read(str_args)); // Since we do the serialization in the v8 extension, we should always get // valid JSON. diff --git a/chrome/service/cloud_print/print_system_cups.cc b/chrome/service/cloud_print/print_system_cups.cc index e3440c7..cbaf2cd 100644 --- a/chrome/service/cloud_print/print_system_cups.cc +++ b/chrome/service/cloud_print/print_system_cups.cc @@ -510,8 +510,7 @@ bool PrintSystemCUPS::IsValidPrinter(const std::string& printer_name) { bool PrintSystemCUPS::ValidatePrintTicket(const std::string& printer_name, const std::string& print_ticket_data) { DCHECK(initialized_); - scoped_ptr<Value> ticket_value(base::JSONReader::Read(print_ticket_data, - false)); + scoped_ptr<Value> ticket_value(base::JSONReader::Read(print_ticket_data)); return ticket_value != NULL && ticket_value->IsType(Value::TYPE_DICTIONARY); } @@ -520,7 +519,7 @@ bool PrintSystemCUPS::ParsePrintTicket( const std::string& print_ticket, std::map<std::string, std::string>* options) { DCHECK(options); - scoped_ptr<Value> ticket_value(base::JSONReader::Read(print_ticket, false)); + scoped_ptr<Value> ticket_value(base::JSONReader::Read(print_ticket)); if (ticket_value == NULL || !ticket_value->IsType(Value::TYPE_DICTIONARY)) return false; diff --git a/chrome/test/automation/automation_json_requests.cc b/chrome/test/automation/automation_json_requests.cc index bc2fbc8..11fc25a 100644 --- a/chrome/test/automation/automation_json_requests.cc +++ b/chrome/test/automation/automation_json_requests.cc @@ -46,7 +46,8 @@ bool SendAutomationJSONRequest(AutomationMessageSender* sender, LOG(INFO) << error->message(); return false; } - scoped_ptr<Value> value(base::JSONReader::Read(reply, true)); + scoped_ptr<Value> value( + base::JSONReader::Read(reply, base::JSON_ALLOW_TRAILING_COMMAS)); if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) { *error = Error("JSON request did not return a dictionary"); LOG(ERROR) << "JSON request did not return dict: " << command << "\n"; diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc index 66a4b0a..4c2dae9 100644 --- a/chrome/test/automation/browser_proxy.cc +++ b/chrome/test/automation/browser_proxy.cc @@ -605,9 +605,8 @@ bool BrowserProxy::GetInitialLoadTimes(int timeout_ms, return false; } std::string error; - base::JSONReader reader; - scoped_ptr<Value> values(reader.ReadAndReturnError(json_response, true, - NULL, &error)); + scoped_ptr<Value> values(base::JSONReader::ReadAndReturnError( + json_response, base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error)); if (!error.empty() || values->GetType() != Value::TYPE_DICTIONARY) return false; diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc index 26e8df9..58f585d 100644 --- a/chrome/test/base/ui_test_utils.cc +++ b/chrome/test/base/ui_test_utils.cc @@ -246,7 +246,8 @@ bool ExecuteJavaScriptHelper(RenderViewHost* render_view_host, json.insert(0, "["); json.append("]"); - scoped_ptr<Value> root_val(base::JSONReader::Read(json, true)); + scoped_ptr<Value> root_val( + base::JSONReader::Read(json, base::JSON_ALLOW_TRAILING_COMMAS)); if (!root_val->IsType(Value::TYPE_LIST)) { DLOG(ERROR) << "JSON result is not a list."; return false; @@ -1105,7 +1106,8 @@ class SnapshotTaker { // Parse the JSON. std::vector<int> dimensions; - scoped_ptr<Value> value(base::JSONReader::Read(json, true)); + scoped_ptr<Value> value( + base::JSONReader::Read(json, base::JSON_ALLOW_TRAILING_COMMAS)); if (!value->IsType(Value::TYPE_LIST)) return false; ListValue* list = static_cast<ListValue*>(value.get()); diff --git a/chrome/test/perf/rendering/throughput_tests.cc b/chrome/test/perf/rendering/throughput_tests.cc index 65ae690..2266de9 100644 --- a/chrome/test/perf/rendering/throughput_tests.cc +++ b/chrome/test/perf/rendering/throughput_tests.cc @@ -68,7 +68,7 @@ class ThroughputTest : public BrowserPerfTest { const std::string& json, int index) { scoped_ptr<base::Value> root; - root.reset(base::JSONReader::Read(json, false)); + root.reset(base::JSONReader::Read(json)); ListValue* root_list = NULL; if (!root.get() || !root->GetAsList(&root_list)) { diff --git a/chrome/test/webdriver/webdriver_dispatch.cc b/chrome/test/webdriver/webdriver_dispatch.cc index 33ac629..d5a2784 100644 --- a/chrome/test/webdriver/webdriver_dispatch.cc +++ b/chrome/test/webdriver/webdriver_dispatch.cc @@ -320,7 +320,7 @@ bool ParseRequestInfo(const struct mg_request_info* const request_info, if (json.length() > 0) { std::string error_msg; scoped_ptr<Value> params(base::JSONReader::ReadAndReturnError( - json, true, NULL, &error_msg)); + json, base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error_msg)); if (!params.get()) { response->SetError(new Error( kBadRequest, diff --git a/chrome/test/webdriver/webdriver_dispatch_unittest.cc b/chrome/test/webdriver/webdriver_dispatch_unittest.cc index 9c4c22a..edee103 100644 --- a/chrome/test/webdriver/webdriver_dispatch_unittest.cc +++ b/chrome/test/webdriver/webdriver_dispatch_unittest.cc @@ -133,7 +133,7 @@ TEST(DispatchTest, ReturnsCommandResponseAsJson) { int error_code; std::string error_message; scoped_ptr<Value> parsed_response(base::JSONReader::ReadAndReturnError( - actual_data, false, &error_code, &error_message)); + actual_data, base::JSON_PARSE_RFC, &error_code, &error_message)); ASSERT_TRUE(parsed_response.get() != NULL) << error_message; ASSERT_TRUE(parsed_response->IsType(Value::TYPE_DICTIONARY)) diff --git a/chrome/test/webdriver/webdriver_session.cc b/chrome/test/webdriver/webdriver_session.cc index 6faabd6..af17a5c 100644 --- a/chrome/test/webdriver/webdriver_session.cc +++ b/chrome/test/webdriver/webdriver_session.cc @@ -1471,7 +1471,7 @@ Error* Session::ExecuteScriptAndParseValue(const FrameId& frame_id, return error; scoped_ptr<Value> value(base::JSONReader::ReadAndReturnError( - response_json, true, NULL, NULL)); + response_json, base::JSON_ALLOW_TRAILING_COMMAS, NULL, NULL)); if (!value.get()) return new Error(kUnknownError, "Failed to parse script result"); if (value->GetType() != Value::TYPE_DICTIONARY) diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc index b479b47..ade6bd7 100644 --- a/chrome/utility/chrome_content_utility_client.cc +++ b/chrome/utility/chrome_content_utility_client.cc @@ -357,8 +357,8 @@ bool ChromeContentUtilityClient::RenderPDFToWinMetafile( void ChromeContentUtilityClient::OnParseJSON(const std::string& json) { int error_code; std::string error; - Value* value = - base::JSONReader::ReadAndReturnError(json, false, &error_code, &error); + Value* value = base::JSONReader::ReadAndReturnError( + json, base::JSON_PARSE_RFC, &error_code, &error); if (value) { ListValue wrapper; wrapper.Append(value); diff --git a/content/browser/geolocation/network_location_request.cc b/content/browser/geolocation/network_location_request.cc index 6ffcb22..8bb6846 100644 --- a/content/browser/geolocation/network_location_request.cc +++ b/content/browser/geolocation/network_location_request.cc @@ -324,7 +324,7 @@ bool ParseServerResponse(const std::string& response_body, // Parse the response, ignoring comments. std::string error_msg; scoped_ptr<Value> response_value(base::JSONReader::ReadAndReturnError( - response_body, false, NULL, &error_msg)); + response_body, base::JSON_PARSE_RFC, NULL, &error_msg)); if (response_value == NULL) { LOG(WARNING) << "ParseServerResponse() : JSONReader failed : " << error_msg; diff --git a/content/browser/speech/google_one_shot_remote_engine.cc b/content/browser/speech/google_one_shot_remote_engine.cc index 7d374fe..452a34a 100644 --- a/content/browser/speech/google_one_shot_remote_engine.cc +++ b/content/browser/speech/google_one_shot_remote_engine.cc @@ -55,7 +55,7 @@ bool ParseServerResponse(const std::string& response_body, // Parse the response, ignoring comments. std::string error_msg; scoped_ptr<Value> response_value(base::JSONReader::ReadAndReturnError( - response_body, false, NULL, &error_msg)); + response_body, base::JSON_PARSE_RFC, NULL, &error_msg)); if (response_value == NULL) { LOG(WARNING) << "ParseServerResponse: JSONReader failed : " << error_msg; return false; diff --git a/gpu/tools/compositor_model_bench/render_tree.cc b/gpu/tools/compositor_model_bench/render_tree.cc index 9e14ca2..c8e928a 100644 --- a/gpu/tools/compositor_model_bench/render_tree.cc +++ b/gpu/tools/compositor_model_bench/render_tree.cc @@ -461,7 +461,7 @@ RenderNode* BuildRenderTreeFromFile(const FilePath& path) { int error_code = 0; string error_message; root.reset(JSONReader::ReadAndReturnError(contents, - true, + base::JSON_ALLOW_TRAILING_COMMAS, &error_code, &error_message)); if (!root.get()) { diff --git a/jingle/glue/utils.cc b/jingle/glue/utils.cc index ffbd23c0..03730ad 100644 --- a/jingle/glue/utils.cc +++ b/jingle/glue/utils.cc @@ -59,7 +59,8 @@ std::string SerializeP2PCandidate(const cricket::Candidate& candidate) { bool DeserializeP2PCandidate(const std::string& candidate_str, cricket::Candidate* candidate) { - scoped_ptr<Value> value(base::JSONReader::Read(candidate_str, true)); + scoped_ptr<Value> value( + base::JSONReader::Read(candidate_str, base::JSON_ALLOW_TRAILING_COMMAS)); if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) { return false; } diff --git a/net/base/crl_set.cc b/net/base/crl_set.cc index 76d6bc3..2e424e5 100644 --- a/net/base/crl_set.cc +++ b/net/base/crl_set.cc @@ -138,7 +138,7 @@ static base::DictionaryValue* ReadHeader(base::StringPiece* data) { data->remove_prefix(header_len); scoped_ptr<Value> header(base::JSONReader::Read( - header_bytes.as_string(), true /* allow trailing comma */)); + header_bytes.as_string(), base::JSON_ALLOW_TRAILING_COMMAS)); if (header.get() == NULL) return NULL; diff --git a/net/base/transport_security_state.cc b/net/base/transport_security_state.cc index 7bc0a31..93b0254 100644 --- a/net/base/transport_security_state.cc +++ b/net/base/transport_security_state.cc @@ -917,8 +917,7 @@ bool TransportSecurityState::Deserialise( const std::string& input, bool* dirty, std::map<std::string, DomainState>* out) { - scoped_ptr<Value> value( - base::JSONReader::Read(input, false /* do not allow trailing commas */)); + scoped_ptr<Value> value(base::JSONReader::Read(input)); if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) return false; diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index 70d481f..1671d71 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -216,7 +216,8 @@ void ChromotingInstance::HandleMessage(const pp::Var& message) { } scoped_ptr<base::Value> json( - base::JSONReader::Read(message.AsString(), true)); + base::JSONReader::Read(message.AsString(), + base::JSON_ALLOW_TRAILING_COMMAS)); base::DictionaryValue* message_dict = NULL; std::string method; base::DictionaryValue* data = NULL; diff --git a/remoting/host/elevated_controller_win.cc b/remoting/host/elevated_controller_win.cc index 1c13ffa..1a8bec6 100644 --- a/remoting/host/elevated_controller_win.cc +++ b/remoting/host/elevated_controller_win.cc @@ -74,7 +74,8 @@ HRESULT ReadConfig(const FilePath& filename, // Parse the JSON configuration, expecting it to contain a dictionary. std::string file_content(buffer.get(), size); - scoped_ptr<base::Value> value(base::JSONReader::Read(file_content, true)); + scoped_ptr<base::Value> value( + base::JSONReader::Read(file_content, base::JSON_ALLOW_TRAILING_COMMAS)); base::DictionaryValue* dictionary; if (value.get() == NULL || !value->GetAsDictionary(&dictionary)) { diff --git a/remoting/host/gaia_oauth_client.cc b/remoting/host/gaia_oauth_client.cc index 8b2844b..0412ae0 100644 --- a/remoting/host/gaia_oauth_client.cc +++ b/remoting/host/gaia_oauth_client.cc @@ -144,7 +144,7 @@ void GaiaOAuthClient::Core::HandleResponse( if (source->GetResponseCode() == net::HTTP_OK) { std::string data; source->GetResponseAsString(&data); - scoped_ptr<Value> message_value(base::JSONReader::Read(data, false)); + scoped_ptr<Value> message_value(base::JSONReader::Read(data)); if (message_value.get() && message_value->IsType(Value::TYPE_DICTIONARY)) { scoped_ptr<DictionaryValue> response_dict( diff --git a/remoting/host/json_host_config.cc b/remoting/host/json_host_config.cc index 66e518c2..6c5c2e8 100644 --- a/remoting/host/json_host_config.cc +++ b/remoting/host/json_host_config.cc @@ -30,7 +30,8 @@ bool JsonHostConfig::Read() { return false; } - scoped_ptr<Value> value(base::JSONReader::Read(file_content, true)); + scoped_ptr<Value> value( + base::JSONReader::Read(file_content, base::JSON_ALLOW_TRAILING_COMMAS)); if (value.get() == NULL || !value->IsType(Value::TYPE_DICTIONARY)) { LOG(WARNING) << "Failed to parse " << filename_.value(); return false; diff --git a/remoting/host/plugin/daemon_controller_win.cc b/remoting/host/plugin/daemon_controller_win.cc index 5369fbb..4b011db 100644 --- a/remoting/host/plugin/daemon_controller_win.cc +++ b/remoting/host/plugin/daemon_controller_win.cc @@ -327,7 +327,8 @@ void DaemonControllerWin::DoGetConfig(const GetConfigCallback& callback) { // Parse the string into a dictionary. scoped_ptr<base::Value> config( - base::JSONReader::Read(UTF16ToUTF8(file_content), true)); + base::JSONReader::Read(UTF16ToUTF8(file_content), + base::JSON_ALLOW_TRAILING_COMMAS)); base::DictionaryValue* dictionary; if (config.get() == NULL || !config->GetAsDictionary(&dictionary)) { diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc index f7f64c8..5743a96 100644 --- a/remoting/host/plugin/host_script_object.cc +++ b/remoting/host/plugin/host_script_object.cc @@ -678,7 +678,8 @@ bool HostNPScriptObject::UpdateDaemonConfig(const NPVariant* args, } std::string config_str = StringFromNPVariant(args[0]); - scoped_ptr<base::Value> config(base::JSONReader::Read(config_str, true)); + scoped_ptr<base::Value> config( + base::JSONReader::Read(config_str, base::JSON_ALLOW_TRAILING_COMMAS)); if (config_str.empty() || !config.get() || !config->IsType(base::Value::TYPE_DICTIONARY)) { SetException("updateDaemonConfig: bad config parameter"); @@ -739,7 +740,8 @@ bool HostNPScriptObject::StartDaemon(const NPVariant* args, } std::string config_str = StringFromNPVariant(args[0]); - scoped_ptr<base::Value> config(base::JSONReader::Read(config_str, true)); + scoped_ptr<base::Value> config( + base::JSONReader::Read(config_str, base::JSON_ALLOW_TRAILING_COMMAS)); if (config_str.empty() || !config.get() || !config->IsType(base::Value::TYPE_DICTIONARY)) { SetException("updateDaemonConfig: bad config parameter"); |