-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Working with google.protobuf.Any in newest version #764
Labels
Comments
can anyone provide an example? |
This works for me, but would be really nice if this was wrapped in some generated helper method protocolbuffers/protobuf#2612 (comment) Eg, in the python library this is much more automatic, as well as in the golang library. |
const protobufjs = require('protobufjs');
const path = require('path');
const protoFilePath = path.resolve(__dirname, './my.proto')
protobufjs.load(protoFilePath, function (
err,
root,
) {
if (err) {
console.error(err);
throw err;
}
const MyMessage = root.lookupType(
'MyMessage',
);
const MyData = root.lookupType(
'MyData',
);
const GoogleAny = root.lookupType('Any');
const myMsg = MyMessage.fromObject({
data: GoogleAny.toObject(
MyData.fromObject({
// ...
})
)
})
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In #677 a wrapper for google.protobuf.Any was added. I wanted to use this because it would be very convenient when working with protobuf.Any, but it did not work. Here is an example based on the unit test comp_google_protobuf_any.js what I would like to do:
Or is there any other way how I can initialize a message that contains a google.protobuf.Any easily?
The text was updated successfully, but these errors were encountered: