Which language are you using? I'm not sure about Java but in C++ I believe you can provide an implementation of the Reporter class and call MessageDifferencer::ReportDifferencesTo(). That will then give you all the information without you needing to parse the summary string.
On Sat, May 25, 2019 at 7:34 PM Kiran Kumar <[email protected]> wrote: > I am using MessageDifferencer API to compute difference between two Google > Protobuf messages. I passed the below two messages to the API. > > > *name: "MSG1"* > > cfgMsg { > > * cfgName: "obj1"* > > * msgId: 100* > > cfgObj { > > uuid: "obj1_1" > > node_id: "1.1.1.1" > > intf_id: 100 > > } > > cfgObj { > > uuid: "obj1_2" > > *node**_id: "2.2.2.2"* > > intf_id: 200 > > } > > cfgObj { > > uuid: "obj1_3" > > node_id: "3.3.3.3" > > intf_id: 300 > > } > > } > > *name: "MSG2"* > > cfgMsg { > > * cfgName: "obj2"* > > *msgId: 200* > > cfgObj { > > uuid: "obj1_1" > > node_id: "1.1.1.1" > > vrf_id: 100 > > } > > cfgObj { > > uuid: "obj1_2" > > *node**_id: "4.4.4.4"* > > vrf_id: 200 > > } > > cfgObj { > > uuid: "obj1_3" > > node_id: "3.3.3.3" > > intf_id: 300 > > } > > *cfgObj {* > > * uuid: "obj1_5"* > > * router_id: "5.5.5.5"* > > * vrf_id: 500* > > * }* > > Output from the Message Differencer API is as below. > > ``` > Message Differences: > modified: name: "MSG1" -> "MSG2" > modified: cfgMsg.cfgName: "obj1" -> "obj2" > modified: cfgMsg.msgId: 100 -> 200 > modified: cfgMsg.cfgObj[1].router_id: "2.2.2.2" -> "4.4.4.4" > added: cfgMsg.cfgObj[3]: { uuid: "obj1_5" router_id: "5.5.5.5" vrf_id: 500 > } > ``` > > My question about this API is: Why does the output is in this format ? It > is not really in any usable format for anyone who is calling this API. The > calling application has to literally do a string parse to make sense of > this output and conclude anything from the returned output. Also, this > output will change depending on how the original message was defined so > getting this parsing in a right way is pretty complex. In fact, even after > parsing it is difficult to match with original message type with either > FieldDescriptor, Reflection or Descriptor. Ideally, returning a new object > of original message type with changed values would make more sense to me. > > Do I understand this API correctly or Am I interpreting the above API > usage in a wrong way ? I don't know if this should be used in conjunction > with any other API to make sense ? > > It will be really helpful for me and I really appreciate if any expect on > this group could explain few details around this ? > > Thanks, > Kiran > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/protobuf/b4b52541-8522-418f-9330-b3f839035947%40googlegroups.com > <https://groups.google.com/d/msgid/protobuf/b4b52541-8522-418f-9330-b3f839035947%40googlegroups.com?utm_medium=email&utm_source=footer> > . > 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. To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/CADqAXr6tET2se3YW931UucnfFd4K%3DO82Laxsa0Z%3DyJ4ss7EsJA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
