For example, I have a proto like this:
message ProtoType
{
string field1 = 1;
strin field2 = 2;
}
And I have a json deserialized from a newer version of this proto:
{
"field1": "111",
"field2": "222",
"testField": "test"
}
I use this to serialize protobuf from json:
JsonParser.Default.Parse<ProtoType>(protojson);
However, if my json has some fields that don't exist in proto (like the testField
below), it will throw an exception:
InvalidProtocolBufferException: Unknown field: testField
I wonder if there's a way to get a ProtoType instance which can automatically ignore unknown fields.
Thanks a lot!