Skip to content
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

Getting the string name of Protobuf object #307

Open
chrisplusplus opened this issue Jul 21, 2022 · 0 comments
Open

Getting the string name of Protobuf object #307

chrisplusplus opened this issue Jul 21, 2022 · 0 comments

Comments

@chrisplusplus
Copy link

I cannot seem to find a way to dynamically get the string name (used in the any.pack function) of an object. The only way I know of is to explicitly pass in a string to the .pack function.

Here is how I currently get the "any" version of my Protobuf objects

const payload = new SysTypes.PbRepeatedUint32Struct();
payload.setValuesList(items);
const any_pb = new GoogleProtobuf.Any;
any_pb.pack(payload.serializeBinary(), 'MpaInterface.PbRepeatedUint32Struct');

Is there a different way to do this without having to know the string ahead of time?

It looks like the generated .js file actually contains a reference to the string I want to use:

proto.MpaInterface.PbRepeatedUint32Struct.displayName = 'proto.MpaInterface.PbRepeatedUint32Struct';

but this property isn't accessible in the generated Typescript files.

Does anyone know how to access the "string name" of the Protobuf object?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant