diff options
Diffstat (limited to 'base/json/json_value_serializer.h')
-rw-r--r-- | base/json/json_value_serializer.h | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/base/json/json_value_serializer.h b/base/json/json_value_serializer.h index 650008e..037302a 100644 --- a/base/json/json_value_serializer.h +++ b/base/json/json_value_serializer.h @@ -39,7 +39,11 @@ class BASE_EXPORT JSONStringValueSerializer : public base::ValueSerializer { // Attempt to serialize the data structure represented by Value into // JSON. If the return value is true, the result will have been written // into the string passed into the constructor. - virtual bool Serialize(const Value& root); + virtual bool Serialize(const Value& root) OVERRIDE; + + // Equivalent to Serialize(root) except binary values are omitted from the + // output. + bool SerializeAndOmitBinaryValues(const Value& root); // Attempt to deserialize the data structure encoded in the string passed // in to the constructor into a structure of Value objects. If the return @@ -48,7 +52,8 @@ class BASE_EXPORT JSONStringValueSerializer : public base::ValueSerializer { // If |error_message| is non-null, it will be filled in with a formatted // error message including the location of the error if appropriate. // The caller takes ownership of the returned value. - virtual Value* Deserialize(int* error_code, std::string* error_message); + virtual Value* Deserialize(int* error_code, std::string* error_message) + OVERRIDE; void set_pretty_print(bool new_value) { pretty_print_ = new_value; } bool pretty_print() { return pretty_print_; } @@ -58,6 +63,8 @@ class BASE_EXPORT JSONStringValueSerializer : public base::ValueSerializer { } private: + bool SerializeInternal(const Value& root, bool omit_binary_values); + std::string* json_string_; bool initialized_with_const_string_; bool pretty_print_; // If true, serialization will span multiple lines. @@ -86,7 +93,11 @@ class BASE_EXPORT JSONFileValueSerializer : public base::ValueSerializer { // Attempt to serialize the data structure represented by Value into // JSON. If the return value is true, the result will have been written // into the file whose name was passed into the constructor. - virtual bool Serialize(const Value& root); + virtual bool Serialize(const Value& root) OVERRIDE; + + // Equivalent to Serialize(root) except binary values are omitted from the + // output. + bool SerializeAndOmitBinaryValues(const Value& root); // Attempt to deserialize the data structure encoded in the file passed // in to the constructor into a structure of Value objects. If the return @@ -95,7 +106,8 @@ class BASE_EXPORT JSONFileValueSerializer : public base::ValueSerializer { // If |error_message| is non-null, it will be filled in with a formatted // error message including the location of the error if appropriate. // The caller takes ownership of the returned value. - virtual Value* Deserialize(int* error_code, std::string* error_message); + virtual Value* Deserialize(int* error_code, std::string* error_message) + OVERRIDE; // This enum is designed to safely overlap with JSONReader::JsonParseError. enum JsonFileError { @@ -117,6 +129,8 @@ class BASE_EXPORT JSONFileValueSerializer : public base::ValueSerializer { static const char* GetErrorMessageForCode(int error_code); private: + bool SerializeInternal(const Value& root, bool omit_binary_values); + FilePath json_file_path_; // A wrapper for file_util::ReadFileToString which returns a non-zero |