diff options
author | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-03 00:37:31 +0000 |
---|---|---|
committer | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-03 00:37:31 +0000 |
commit | 1c1c77a5021be0b902240a4f78009a8d8f71d1ac (patch) | |
tree | c1afb46b67de923afaac68340ddb0113b7306193 /base/json | |
parent | 23b3f6c67270a6aff5020c9a7279f4ed84192a02 (diff) | |
download | chromium_src-1c1c77a5021be0b902240a4f78009a8d8f71d1ac.zip chromium_src-1c1c77a5021be0b902240a4f78009a8d8f71d1ac.tar.gz chromium_src-1c1c77a5021be0b902240a4f78009a8d8f71d1ac.tar.bz2 |
Submitting change from http://codereview.chromium.org/276029/show
BUG=none
TEST=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30778 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/json')
-rw-r--r-- | base/json/json_writer.cc | 6 | ||||
-rw-r--r-- | base/json/json_writer.h | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/base/json/json_writer.cc b/base/json/json_writer.cc index dffa3da..133b625 100644 --- a/base/json/json_writer.cc +++ b/base/json/json_writer.cc @@ -19,6 +19,9 @@ static const char kPrettyPrintLineEnding[] = "\n"; #endif /* static */ +const char* JSONWriter::kEmptyArray = "[]"; + +/* static */ void JSONWriter::Write(const Value* const node, bool pretty_print, std::string* json) { @@ -48,7 +51,7 @@ JSONWriter::JSONWriter(bool pretty_print, std::string* json) void JSONWriter::BuildJSONString(const Value* const node, int depth, bool escape) { - switch(node->GetType()) { + switch (node->GetType()) { case Value::TYPE_NULL: json_string_->append("null"); break; @@ -147,7 +150,6 @@ void JSONWriter::BuildJSONString(const Value* const node, for (DictionaryValue::key_iterator key_itr = dict->begin_keys(); key_itr != dict->end_keys(); ++key_itr) { - if (key_itr != dict->begin_keys()) { json_string_->append(","); if (pretty_print_) diff --git a/base/json/json_writer.h b/base/json/json_writer.h index 29aa69d..0ebee0a 100644 --- a/base/json/json_writer.h +++ b/base/json/json_writer.h @@ -33,6 +33,10 @@ class JSONWriter { bool escape, std::string* json); + // A static, constant JSON string representing an empty array. Useful + // for empty JSON argument passing. + static const char* kEmptyArray; + private: JSONWriter(bool pretty_print, std::string* json); |