Representing variable JSON object data in a message

78 views Asked by At

Using protobufjs, I'm trying to define a message that would have a field holding a standard JSON object.

In my Typescript code, I use

import {Field, Type} from 'protobufjs/light';

@Type.d('MyType')
class MyType {
    @Field.d(1, 'google.protobuf.Struct', 'required')
    public element: Record<string, unknown>;
}

At runtime, I get a failure with the message

Error: no such Type or Enum 'google.protobuf.Struct' in Type

What am I doing wrong? Is it possible to have messages containing variable JSON object data?

0

There are 0 answers