diff options
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); |