how to convert YANG data model to JSON data?

13,261
  1. Convert yang to xml using pyang -f yin filename
  2. Convert xml file to json using any of the solutions below https://stackoverflow.com/a/10201397/3283069 https://stackoverflow.com/a/6465496/3283069
Share:
13,261
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    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?

  • Alexander Bird
    Alexander Bird over 6 years
    yang is a modeling language. json is a modeling language. It is very rational to convert data into a different format for different tools
  • kikas
    kikas over 4 years
    Yang 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.
  • Dave
    Dave over 2 years
    This 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.