protobuf.js
protobuf.js copied to clipboard
Missing valuesOptions in fromJSON parser function
Hi! 👋
I've found out the "valuesOptions" option in Enum class is missing when parsed from the JSON.
Reproduction:
- Create .proto file containing an enum with the valuesOptions
- Generate JSON from this .proto file
- Parse the generated JSON back
- Try to access the valuesOptions field in that enum
The following code change should fix it:
diff --git a/node_modules/protobufjs/src/enum.js b/node_modules/protobufjs/src/enum.js
index 1c01620..730b8e4 100644
--- a/node_modules/protobufjs/src/enum.js
+++ b/node_modules/protobufjs/src/enum.js
@@ -87,7 +87,7 @@ function Enum(name, values, options, comment, comments, valuesOptions) {
* @throws {TypeError} If arguments are invalid
*/
Enum.fromJSON = function fromJSON(name, json) {
- var enm = new Enum(name, json.values, json.options, json.comment, json.comments);
+ var enm = new Enum(name, json.values, json.options, json.comment, json.comments, json.valuesOptions);
enm.reserved = json.reserved;
return enm;
};
This issue body was partially generated by patch-package.