I have a json file which I want to convert to proto java file.
Is there any direct way of doing so ?
I have tried reading the file into string and then converting the string to proto messge , but failed to do so , I keep getting
com.google.protobuf.InvalidProtocolBufferException: JsonObject
at JsonFormat.parser().usingTypeRegistry(TypeRegistry.getEmptyTypeRegistry()).merge(jsonConfig, messageBuilder);
here is my json:
{
"a": 123,
"b": {
"b1": [
{
"id": "123"
}
]
},
"c": 30,
"d": [
"d1",
"d2"
],
"e": [
{
"e1": "ads",
"e2": "asd"
}
]
}
尝试:
JsonFormat.parser().merge(json, request);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.