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.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/google/protobuf/util/internal/json_objectwriter.cc b/src/google/protobuf/util/internal/json_objectwriter.cc
index 6e4edd88..c36459a4 100644
--- a/src/google/protobuf/util/internal/json_objectwriter.cc
+++ b/src/google/protobuf/util/internal/json_objectwriter.cc
@@ -176,8 +176,14 @@ void JsonObjectWriter::WritePrefix(StringPiece name) {
if (!name.empty() || empty_key_ok) {
WriteChar('"');
if (!name.empty()) {
- ArrayByteSource source(name);
- JsonEscaping::Escape(&source, &sink_);
+ if (use_snake_case_for_field_names_) {
+ string snake_name = ToSnakeCase(name);
+ ArrayByteSource source(snake_name);
+ JsonEscaping::Escape(&source, &sink_);
+ } else {
+ ArrayByteSource source(name);
+ JsonEscaping::Escape(&source, &sink_);
+ }
}
stream_->WriteString("\":");
if (!indent_string_.empty()) WriteChar(' ');