| Index: base/json/json_value_serializer.cc
|
| diff --git a/base/json/json_value_serializer.cc b/base/json/json_value_serializer.cc
|
| index d667bc198e76fe7c19cdc0a3af0667982fbfade0..89f13a2b4b579db06f163d1d0a4d34f8c693c2fe 100644
|
| --- a/base/json/json_value_serializer.cc
|
| +++ b/base/json/json_value_serializer.cc
|
| @@ -17,10 +17,24 @@ const char* JSONFileValueSerializer::kNoSuchFile = "File doesn't exist.";
|
| JSONStringValueSerializer::~JSONStringValueSerializer() {}
|
|
|
| bool JSONStringValueSerializer::Serialize(const Value& root) {
|
| + return SerializeInternal(root, false);
|
| +}
|
| +
|
| +bool JSONStringValueSerializer::SerializeAndOmitBinaryValues(
|
| + const Value& root) {
|
| + return SerializeInternal(root, true);
|
| +}
|
| +
|
| +bool JSONStringValueSerializer::SerializeInternal(const Value& root,
|
| + bool omit_binary_values) {
|
| if (!json_string_ || initialized_with_const_string_)
|
| return false;
|
|
|
| - base::JSONWriter::Write(&root, pretty_print_, json_string_);
|
| + base::JSONWriter::WriteWithOptions(
|
| + &root,
|
| + pretty_print_,
|
| + omit_binary_values ? base::JSONWriter::OPTIONS_OMIT_BINARY_VALUES : 0,
|
| + json_string_);
|
| return true;
|
| }
|
|
|
| @@ -38,10 +52,21 @@ Value* JSONStringValueSerializer::Deserialize(int* error_code,
|
| /******* File Serializer *******/
|
|
|
| bool JSONFileValueSerializer::Serialize(const Value& root) {
|
| + return SerializeInternal(root, false);
|
| +}
|
| +
|
| +bool JSONFileValueSerializer::SerializeAndOmitBinaryValues(const Value& root) {
|
| + return SerializeInternal(root, true);
|
| +}
|
| +
|
| +bool JSONFileValueSerializer::SerializeInternal(const Value& root,
|
| + bool omit_binary_values) {
|
| std::string json_string;
|
| JSONStringValueSerializer serializer(&json_string);
|
| serializer.set_pretty_print(true);
|
| - bool result = serializer.Serialize(root);
|
| + bool result = omit_binary_values ?
|
| + serializer.SerializeAndOmitBinaryValues(root) :
|
| + serializer.Serialize(root);
|
| if (!result)
|
| return false;
|
|
|
|
|