jschema-to-python is a utility that generates Python source code for data classes directly from a JSON schema. As of version 1.2.3, it provides functionality to translate schema definitions into Python classes, complete with type hints and properties. The library, maintained by Microsoft, has an irregular release cadence, typically driven by internal needs or significant updates.
pip install jschema-to-pythonVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a JSON schema, use `jschema_to_python.generate_code` to convert it into a Python class string, and then explicitly write that string to a `.py` file. It also shows how to configure `CodeGeneratorOptions` to influence the generated code's style.
Ensure your environment uses Python 3.8 or newer when generating code with this library to leverage contemporary Python features and maintain future compatibility.
After calling `generate_code`, use standard Python file I/O operations (e.g., `with open('your_module_name.py', 'w') as f: f.write(generated_code_string)`) to persist the generated code.Pass `CodeGeneratorOptions(disable_formatter=True)` to the `generate_code` or `generate_code_from_file` function if you need to control the formatting externally or prefer unformatted output.
No dependency data recorded yet.