Chromium Code Reviews| Index: base/json/json_writer.h |
| diff --git a/base/json/json_writer.h b/base/json/json_writer.h |
| index 1eeecb913ac8d0c283bffc172acdf606b9cbefe2..e4f4c31f11e0ec3470528dbf1db03771cf3a5b79 100644 |
| --- a/base/json/json_writer.h |
| +++ b/base/json/json_writer.h |
| @@ -17,6 +17,16 @@ class Value; |
| class BASE_EXPORT JSONWriter { |
| public: |
| + enum Options { |
| + // Do not escape the string, preserving its UTF8 characters. It is useful |
| + // if you can pass the resulting string to the JSON parser in binary form |
| + // (as UTF8). |
| + OPTIONS_DO_NOT_ESCAPE = 1 << 0, |
| + |
| + // Ignore values of binary type. They will be omitted from the output. |
|
Jói
2011/11/10 11:08:16
This is slightly vague: _values_ ... will be omit
Eric Dingle
2011/11/10 15:05:25
Done.
|
| + OPTIONS_IGNORE_BINARY_VALUES = 1 << 1 |
| + }; |
| + |
| // Given a root node, generates a JSON string and puts it into |json|. |
| // If |pretty_print| is true, return a slightly nicer formated json string |
| // (pads with whitespace to help readability). If |pretty_print| is false, |
| @@ -27,13 +37,10 @@ class BASE_EXPORT JSONWriter { |
| static void Write(const Value* const node, bool pretty_print, |
| std::string* json); |
| - // Same as above, but has an option to not escape the string, preserving its |
| - // UTF8 characters. It is useful if you can pass resulting string to the |
| - // JSON parser in binary form (as UTF8). |
| - static void WriteWithOptionalEscape(const Value* const node, |
| - bool pretty_print, |
| - bool escape, |
| - std::string* json); |
| + // Same as above but with |options| which is a bunch of JSONWriter::Options |
| + // bitwise ORed together. |
| + static void Write(const Value* const node, bool pretty_print, |
| + int options, std::string* json); |
| // A static, constant JSON string representing an empty array. Useful |
| // for empty JSON argument passing. |
| @@ -44,7 +51,8 @@ class BASE_EXPORT JSONWriter { |
| // Called recursively to build the JSON string. Whe completed, value is |
| // json_string_ will contain the JSON. |
| - void BuildJSONString(const Value* const node, int depth, bool escape); |
| + void BuildJSONString(const Value* const node, int depth, bool escape, |
| + bool ignore_binary_values); |
| // Appends a quoted, escaped, version of (UTF-8) str to json_string_. |
| void AppendQuotedString(const std::string& str); |