Open
Description
protobuf.js version: 6.8.0
I've run into an issue a few times when parsing JSON data into the statically generated classes, when the fields in the JSON data are named using using the json_name annotation for the field names instead of the normal field names.
For example, if a proto file looks like:
import "google/api/annotations.proto";
import "otherstuff.proto";
message MyClass {
repeated Thing thing = 1 [json_name="my_things"];
}
And you are parsing in the object like
const myObject = MyClass.fromObject(someObjectParsedFromJsonData);
the object field currently needs to be named thing
instead of my_things
.
It would be nice if the alternate naming scheme could be used directly, either through a command line switch or using another method like fromJson() in place of fromObject().
Metadata
Metadata
Assignees
Labels
No labels