diff options
Diffstat (limited to 'csharp/src/ProtocolBuffers/JsonFormatter.cs')
-rw-r--r-- | csharp/src/ProtocolBuffers/JsonFormatter.cs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/csharp/src/ProtocolBuffers/JsonFormatter.cs b/csharp/src/ProtocolBuffers/JsonFormatter.cs index 3e2244d6..9bd628eb 100644 --- a/csharp/src/ProtocolBuffers/JsonFormatter.cs +++ b/csharp/src/ProtocolBuffers/JsonFormatter.cs @@ -141,6 +141,7 @@ namespace Google.Protobuf { var descriptor = accessor.Descriptor; // Oneofs are written later + // TODO: Change to write out fields in order, interleaving oneofs appropriately (as per binary format) if (descriptor.ContainingOneof != null) { continue; @@ -176,7 +177,7 @@ namespace Google.Protobuf { continue; } - var fieldAccessor = fields[fieldDescriptor]; + var fieldAccessor = fields[fieldDescriptor.FieldNumber]; object value = fieldAccessor.GetValue(message); // Omit awkward (single) values such as unknown enum values if (!fieldDescriptor.IsRepeated && !fieldDescriptor.IsMap && !CanWriteSingleValue(fieldDescriptor, value)) |