I have RepeatedMessage in my proto file, I am able to create C# object of my proto and serialize it and so..whereas , when I pass the value via JSON with only one value in collection , it threw error as
Unhandled Exception: Google.Protobuf.InvalidProtocolBufferException: Repeated field value was not an array. Token type: StartObject
at Google.Protobuf.JsonParser.MergeRepeatedField(IMessage message, FieldDescriptor field, JsonTokenizer tokenizer)
at Google.Protobuf.JsonParser.MergeField(IMessage message, FieldDescriptor field, JsonTokenizer tokenizer)
at Google.Protobuf.JsonParser.Merge(IMessage message, JsonTokenizer tokenizer)
at Google.Protobuf.JsonParser.Merge(IMessage message, TextReader jsonReader)
at Google.Protobuf.JsonParser.Parse(TextReader jsonReader, MessageDescriptor descriptor)
at Google.Protobuf.JsonParser.Parse(String json, MessageDescriptor descriptor)
My question is , how to have only one value in RepeatedMessageField, how to set this in JSON parser settings ?
Repeated Message is : desiredParameters
I am using Google protobuf JSON parser to parse JSON value,
Google.Protobuf.JsonParser parser = Google.Protobuf.JsonParser.Default;
IMessage tt = parser.Parse(json, descriptor);
And Error JSON value is
{
"destinationPort": "25",
"desiredParameters": [
{
"context": "J1939_PGN",
"value": "12340000"
}
]
}
Where as if I give two or more desired parameters list as like below , then it works,
{
"destinationPort": "25",
"desiredParameters": [
{
"context": "J1939_PGN",
"value": "12340000"
},
{
"context": "J1939_SPN",
"value": "1245"
}
]
}