Oneof fields are great for representing that, though: https://developers.google.com/protocol-buffers/docs/proto#oneof
On Tue, Feb 13, 2018 at 10:15 AM, Yaseen Khan <[email protected]> wrote: > But a single message can have various data types as seen in the example.. > The message Master {..} > > On 13-Feb-2018 23:41, "Adam Cozzette" <[email protected]> wrote: > > I mean to say just don't rely on the field names at all, and instead store > all the information you need in the serialized message. For example, your > serialized message could store a map<string, DataType> that maps the string > property name to another message called DataType describing the kind of > data associated with that property. > > On Tue, Feb 13, 2018 at 10:05 AM, Yaseen Khan <[email protected]> > wrote: > >> I'm sorry I don't understand. How would you serialise the field names? >> >> On 13-Feb-2018 23:32, "Adam Cozzette" <[email protected]> wrote: >> >>> Ah, I see. I would try to find a way to do this without trying to rely >>> on reflection, perhaps by serializing the names you need inside a proto >>> message without using the actual field names. >>> >>> On Tue, Feb 13, 2018 at 9:28 AM, Yaseen Khan <[email protected]> >>> wrote: >>> >>>> A dynamic form needs keys and values(if any) to be fed to it to create >>>> a form. I was thinking I could get the names of the properties in a msg >>>> with a descriptor and feeding it to create a dynamic form. >>>> >>>> Although a crude way of doing it is converting the jspb proto object to >>>> a normal Object and reading its keys,.. I didn't find it to be a good >>>> approach. >>>> >>>> On 13-Feb-2018 22:52, "Adam Cozzette" <[email protected]> wrote: >>>> >>>>> But ordinarily you parse messages without needing any descriptors--why >>>>> do need a descriptor to read your message? >>>>> >>>>> On Tue, Feb 13, 2018 at 9:20 AM, Yaseen Khan < >>>>> [email protected]> wrote: >>>>> >>>>>> Trying to create dynamic forms by reading proto msgs. >>>>>> >>>>>> On 13-Feb-2018 22:48, "Adam Cozzette" <[email protected]> wrote: >>>>>> >>>>>>> What do you want to do with the descriptors? >>>>>>> >>>>>>> On Mon, Feb 12, 2018 at 10:15 PM, Yaseen Khan < >>>>>>> [email protected]> wrote: >>>>>>> >>>>>>>> So, could you possibly give me the work around for it? It would be >>>>>>>> very helpful. Thanks! >>>>>>>> >>>>>>>> On Friday, 9 February 2018 17:06:45 UTC+5:30, Yaseen Khan wrote: >>>>>>>>> >>>>>>>>> I'm trying to get the descriptor for my proto message. In java >>>>>>>>> there is this, Message.getDescriptor() >>>>>>>>> which does the job but its hard to find something similar in jspb. >>>>>>>>> >>>>>>>>> syntax = "proto3"; >>>>>>>>> >>>>>>>>> message Master { >>>>>>>>> int32 id = 1; >>>>>>>>> string name = 2; >>>>>>>>> Type type = 3; >>>>>>>>> } >>>>>>>>> >>>>>>>>> enum Type { >>>>>>>>> UNKNOWN_TYPE = 0; >>>>>>>>> INDUSTRY_TYPE = 1; >>>>>>>>> LOCATION_TYPE = 2; >>>>>>>>> } >>>>>>>>> >>>>>>>>> This is the message of which i want the descriptor of. >>>>>>>>> >>>>>>>> -- >>>>>>>> You received this message because you are subscribed to the Google >>>>>>>> Groups "Protocol Buffers" group. >>>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>>> send an email to [email protected]. >>>>>>>> To post to this group, send email to [email protected]. >>>>>>>> Visit this group at https://groups.google.com/group/protobuf. >>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>> >>>>>>> >>>>>>> >>>>> >>> > > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
