How do I convert "YANG" data model to "JSON"? As there is many many docs available in web, in that they changed in YANG synatx to JSON but how the value for the leaf or leaf list they are getting? from where and how it will get actual data in JSON from YANG?
Asked
Active
Viewed 1.7k times
2 Answers
4
- Convert yang to xml using pyang -f yin filename
- Convert xml file to json using any of the solutions below https://stackoverflow.com/a/10201397/3283069 https://stackoverflow.com/a/6465496/3283069

Community
- 1
- 1

user3283069
- 355
- 1
- 6
-
2This does not work, also its messy. The yang structure is a structure language. Converting to "JSON" or "XML" is based on the structure of the system using it, so this process is not as easy as "feed the yang into a converter". You need to read documentation, and understand the structure of the system trying to process yang models. – Dave Sep 02 '21 at 18:26
-4
Yang is a modeling language, not a data generation language.
What you are asking for is a simulator that will contain the same or pseudo logic as your application to generate data.

kikas
- 1
- 1
-
3yang is a modeling language. json is a modeling language. It is very rational to convert data into a different format for different tools – Alexander Bird Oct 24 '17 at 20:36
-
2Yang is equivalent to JSON-schema. You can generate JSON objects from Yang models but not convert Yang to JSON unless I am not understanding this right. – kikas Sep 13 '19 at 19:05