aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/util/internal/json_objectwriter.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/util/internal/json_objectwriter.cc')
-rw-r--r--src/google/protobuf/util/internal/json_objectwriter.cc13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/google/protobuf/util/internal/json_objectwriter.cc b/src/google/protobuf/util/internal/json_objectwriter.cc
index 6e4edd88..a431177a 100644
--- a/src/google/protobuf/util/internal/json_objectwriter.cc
+++ b/src/google/protobuf/util/internal/json_objectwriter.cc
@@ -57,7 +57,7 @@ JsonObjectWriter::~JsonObjectWriter() {
JsonObjectWriter* JsonObjectWriter::StartObject(StringPiece name) {
WritePrefix(name);
WriteChar('{');
- Push();
+ PushObject();
return this;
}
@@ -71,7 +71,7 @@ JsonObjectWriter* JsonObjectWriter::EndObject() {
JsonObjectWriter* JsonObjectWriter::StartList(StringPiece name) {
WritePrefix(name);
WriteChar('[');
- Push();
+ PushArray();
return this;
}
@@ -172,8 +172,7 @@ void JsonObjectWriter::WritePrefix(StringPiece name) {
bool not_first = !element()->is_first();
if (not_first) WriteChar(',');
if (not_first || !element()->is_root()) NewLine();
- bool empty_key_ok = GetAndResetEmptyKeyOk();
- if (!name.empty() || empty_key_ok) {
+ if (!name.empty() || element()->is_json_object()) {
WriteChar('"');
if (!name.empty()) {
ArrayByteSource source(name);
@@ -184,12 +183,6 @@ void JsonObjectWriter::WritePrefix(StringPiece name) {
}
}
-bool JsonObjectWriter::GetAndResetEmptyKeyOk() {
- bool retval = empty_name_ok_for_next_key_;
- empty_name_ok_for_next_key_ = false;
- return retval;
-}
-
} // namespace converter
} // namespace util
} // namespace protobuf