How to define a generic map in proto file for entries in map<string, Object> in java?

2.4k Views Asked by At

I'm trying to write a proto file having generic map so that when I fetch the data from database in json format, it can be converted to proto format? Is there anyway to do this ?

Here is the image of the entries present in the database for which, proto file needs to written.

For example: I need to write a generic map in proto file in such a way that all the entries in the "PROPERTY_CATEGORY" should be converted to proto.

1

There are 1 best solutions below

0
On

You can either use an Any or a struct to accomplish this

  1. map<string, google.protobuf.Any>

  2. Struct https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/struct.proto#L51