2

Consider the following use case:

I have the configuration of a network router (OpenWRT) in text format that I'm converting to JSON (NetJSON to be specific), the text format used by the router only uses strings and I have to convert many configuration attributes from string to booleans and integers.

I would like to query the JSON Schema to automatically determine what is the expected type of the attributes and perform the right conversion.

The JSON schema we are using is quite complex, contains many definitions that are merged using allOf, anyOf, etc, therefore just looping on a specific part of the schema is not good enough.

Is there a way to do this using the python jsonschema library or are there alternative ways of doing it?

PS: the implementation of this feature is open source, you can find out more about the OpenWISP netjsonconfig library and the pull request to add the backward conversion feature into the library.

nemesisdesign
  • 8,159
  • 12
  • 58
  • 97

0 Answers0