aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/JsonFormatter.cs
diff options
context:
space:
mode:
authoralien <the-alien@live.ru>2016-03-17 15:19:04 +0300
committeralien <the-alien@live.ru>2016-03-18 22:59:50 +0300
commit0d32ab37fa94134427478d6776108e7cdb3e5e15 (patch)
treeb0f5e3c9f9bf9097f739b98d0503d659abe974a9 /csharp/src/Google.Protobuf/JsonFormatter.cs
parent5e933847cc9e7826f1a9ee8b3dc1df4960b1ea5d (diff)
downloadprotobuf-0d32ab37fa94134427478d6776108e7cdb3e5e15.tar.gz
protobuf-0d32ab37fa94134427478d6776108e7cdb3e5e15.tar.bz2
protobuf-0d32ab37fa94134427478d6776108e7cdb3e5e15.zip
csharp: add support for the json_name option
Conflicts: csharp/src/Google.Protobuf/JsonFormatter.cs
Diffstat (limited to 'csharp/src/Google.Protobuf/JsonFormatter.cs')
-rw-r--r--csharp/src/Google.Protobuf/JsonFormatter.cs7
1 files changed, 5 insertions, 2 deletions
diff --git a/csharp/src/Google.Protobuf/JsonFormatter.cs b/csharp/src/Google.Protobuf/JsonFormatter.cs
index eb959c9f..1b5349e9 100644
--- a/csharp/src/Google.Protobuf/JsonFormatter.cs
+++ b/csharp/src/Google.Protobuf/JsonFormatter.cs
@@ -237,11 +237,14 @@ namespace Google.Protobuf
{
writer.Write(PropertySeparator);
}
- WriteString(writer, ToCamelCase(accessor.Descriptor.Name));
+
+ WriteString(writer, string.IsNullOrEmpty(accessor.Descriptor.JsonName) ?
+ ToCamelCase(accessor.Descriptor.Name) : accessor.Descriptor.JsonName);
writer.Write(NameValueSeparator);
WriteValue(writer, value);
+
first = false;
- }
+ }
return !first;
}