Skip to content

Getting the string name of Protobuf object #307

@chrisplusplus

Description

@chrisplusplus

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions