aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/JsonParser.cs
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/Google.Protobuf/JsonParser.cs')
-rw-r--r--csharp/src/Google.Protobuf/JsonParser.cs8
1 files changed, 2 insertions, 6 deletions
diff --git a/csharp/src/Google.Protobuf/JsonParser.cs b/csharp/src/Google.Protobuf/JsonParser.cs
index 9e5d8711..92029e06 100644
--- a/csharp/src/Google.Protobuf/JsonParser.cs
+++ b/csharp/src/Google.Protobuf/JsonParser.cs
@@ -617,13 +617,9 @@ namespace Google.Protobuf
return (float) value;
case FieldType.Enum:
CheckInteger(value);
- var enumValue = field.EnumType.FindValueByNumber((int) value);
- if (enumValue == null)
- {
- throw new InvalidProtocolBufferException($"Invalid enum value: {value} for enum type: {field.EnumType.FullName}");
- }
// Just return it as an int, and let the CLR convert it.
- return enumValue.Number;
+ // Note that we deliberately don't check that it's a known value.
+ return (int) value;
default:
throw new InvalidProtocolBufferException($"Unsupported conversion from JSON number for field type {field.FieldType}");
}