Skip to content

lkekana/py-classes-from-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py-classes-from-json

Generate Python classes using one or more JSON strings. Uses both genson and Microsoft's jschema-to-python to achieve this.

Installation

git clone (this repo)
pip install -r requirements.txt

Usage

usage: python make.py [-h] [--input-dir INPUT_DIR] [--output-dir OUTPUT_DIR]
               [--root-class-name ROOT_CLASS_NAME] [--module-name MODULE_NAME]
               [-v]

Generate a JSON schema and Python class from one or more JSON files.

optional arguments:
  -h, --help            show this help message and exit
  --input-dir INPUT_DIR
                        Path to input directory
  --output-dir OUTPUT_DIR
                        Path to output directory
  --root-class-name ROOT_CLASS_NAME
                        Name of root class / parent object
  --module-name MODULE_NAME
                        Name of Python module
  -v, --verbose         Increase output verbosity

Example

python make.py --input-dir ./examples --output-dir ./examples --root-class-name JobEvent --module-name myEvents

You can also test the generated classes by running the following (in the examples folder)

python test.py

Thanks to

About

Generate Python classes using JSON strings

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages