Answers for "generate schema from json python"

2

generate schema from json python

#Example usage of generating python code
from jsonschemacodegen import python as pygen
import json

with open('schema.json') as fp:
    generator = pygen.GeneratorFromSchema('output_dir')
    generator.Generate(json.load(fp), 'Example', 'example')

#using the generated code looks like

import example
import json

jsonText = '["an example string in an array"]'

obj = example.Example(json.loads(jsonText))

print(json.dumps(obj, default=lambda x: x.Serializable()))
Posted by: Guest on May-31-2021

Code answers related to "generate schema from json python"

Code answers related to "Javascript"

Browse Popular Code Answers by Language