Python JSON Schema Grammar interpreter
Maintained. Last release 7 weeks ago, commits in 4 of the last 26 weeks. Weaker on commit activity.
$
pip install pyjsgThis repository was originally developed by Harold Solbrig and was kindly contributed to the LinkML organization because of his retirement. All credit for the original development of this repository goes to him.
PyJSG -- JSON Schema Grammar Bindings for Python
Translate JSON Schema Grammar into Python objects.
This tool generates Python 3 objects that represent the JSON objects defined in a JSG schema. It uses the Python Typing library to add type hints to Python IDE's and includes a library to validate the python objects against the library definitions.
Examples
| JSON Grammar | Python Objects | |
|---|---|---|
doc { status:"ready" } |
class _Anon1(jsg.JSGString):
pattern = jsg.JSGPattern(r'ready') | |
doc { street:@string no:@int }
| class doc(jsg.JSGObject):
def __init__(self,
street: str = None,
no: int = None,
**_kwargs: Dict[str, object]):
self.street = jsg.String(street)
self.no = jsg.Integer(no)
super().__init__(self._context, **_kwargs)
| |
doc { street:(NAME|"*"|TEMPLATE) } | class _Anon1(jsg.JSGString):
pattern = jsg.JSGPattern(r'\*') |