The use case is parsing idls in service A and parsing protobuf messages to json in service B.
Using jhump.protoreflect to parse idl and get desc.MessageDescriptor, then use protojson to marshal descriptorpb.DescriptorProto
h, _ := protojson.Marshal(md.Descriptor.AsDescriptorProto())
Using protojson to unmarshal h and get DescriptorProto
var z descriptorpb.ç if err := protojson.Unmarshal(h, &z); err != nil { fmt.Println(err.Error()) }
How to parse message by using DescriptorProto?
If I'm doing the whole work in the same service, I'm able to parse the message by using MessageDescriptor
dm := dynamic.NewMessage(md)
dm.Unmarshal(body)
dm.MarshalJSONPB(&jsonpb.Marshaler{OrigName: true, EnumsAsInts: true})
but the issue is parsing message is done in a different service, so I'm looking to keep some "message descriptor" in database and can be used by service B.
Any suggestion?