Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate proto input message from json #124

Open
shushukl-cisco opened this issue Apr 1, 2020 · 1 comment
Open

Generate proto input message from json #124

shushukl-cisco opened this issue Apr 1, 2020 · 1 comment

Comments

@shushukl-cisco
Copy link

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?

@robshakir
Copy link
Contributor

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 a gnmi.Path protobuf message.
  • <generated package>.Unmarshal combined with ygot.TogNMINotifications -- this will allow you to unmarshal an RFC7951-compliant JSON output into a ygot-generated Go struct, the TogNMINotifications will then marshal its contents as a set of gnmi.Notification messages containing both the path and value.

Cheers,
r.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants