reference
reference copied to clipboard
Generate proto input message from json
Hi,
I want to generate proto inputs in this format from a json equivalent. Is there a way to do so?
path: < elem: < name: "a"
elem: < name: "b"
elem: < name: "c"
elem: < name: "d"
Or is there some proto structure / library I can use to dynamically populate proto structures like the above?
What is the format of the JSON input that you have? There are two sets of functions that might be of interest in ygot for this:
ygot.StringToStructuredPath-- this will take an input path string (per this spec) and convert it to agnmi.Pathprotobuf message.<generated package>.Unmarshalcombined withygot.TogNMINotifications-- this will allow you to unmarshal an RFC7951-compliant JSON output into a ygot-generated Go struct, theTogNMINotificationswill then marshal its contents as a set ofgnmi.Notificationmessages containing both the path and value.
Cheers, r.