summaryrefslogtreecommitdiffstats
path: root/chrome/common/json_value_serializer.h
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-29 00:21:49 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-29 00:21:49 +0000
commit94d126b3ce7e1f3100897240884a00f3b7e96575 (patch)
tree51306cea1e41d88f10ef3554f89c2208f5512583 /chrome/common/json_value_serializer.h
parentad89a6dc97029138b9f7f04135f3e8e164491eb5 (diff)
downloadchromium_src-94d126b3ce7e1f3100897240884a00f3b7e96575.zip
chromium_src-94d126b3ce7e1f3100897240884a00f3b7e96575.tar.gz
chromium_src-94d126b3ce7e1f3100897240884a00f3b7e96575.tar.bz2
Update the JSONValueSerializer to have a flag to allow trailing commas. By default, we don't support this when deserializing JSON, but the user can enable this.
BUG=1295713 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/json_value_serializer.h')
-rw-r--r--chrome/common/json_value_serializer.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/chrome/common/json_value_serializer.h b/chrome/common/json_value_serializer.h
index 6f3c067..ff18104 100644
--- a/chrome/common/json_value_serializer.h
+++ b/chrome/common/json_value_serializer.h
@@ -43,14 +43,16 @@ class JSONStringValueSerializer : public ValueSerializer {
JSONStringValueSerializer(std::string* json_string)
: json_string_(json_string),
initialized_with_const_string_(false),
- pretty_print_(false) {
+ pretty_print_(false),
+ allow_trailing_comma_(false) {
}
// This version allows initialization with a const string reference for
// deserialization only.
JSONStringValueSerializer(const std::string& json_string)
: json_string_(&const_cast<std::string&>(json_string)),
- initialized_with_const_string_(true) {
+ initialized_with_const_string_(true),
+ allow_trailing_comma_(false) {
}
~JSONStringValueSerializer();
@@ -70,10 +72,16 @@ class JSONStringValueSerializer : public ValueSerializer {
void set_pretty_print(bool new_value) { pretty_print_ = new_value; }
bool pretty_print() { return pretty_print_; }
+ bool set_allow_trailing_comma(bool new_value) {
+ allow_trailing_comma_ = new_value;
+ }
+
private:
std::string* json_string_;
bool initialized_with_const_string_;
bool pretty_print_; // If true, serialization will span multiple lines.
+ // If true, deserialization will allow trailing commas.
+ bool allow_trailing_comma_;
DISALLOW_EVIL_CONSTRUCTORS(JSONStringValueSerializer);
};