Quick Start (Python Code)
Module ranjg
can be used in python code.
If you haven’t installed ranjg yet, install it with the following command:
$ pip install ranjg
Then, you can generate values according to ranjg-JSON-schema with following code.
>>> import ranjg
>>> schema = {
... 'type': 'object',
... 'required': ['name'],
... 'properties': {
... 'name': { 'type': 'string', 'minLength': 1 },
... 'age': { 'type': 'integer', 'minimum': 0 },
... }
... }
>>> generated = ranjg.gen(schema)
The schema
specified in the above example is according to ranjg-JSON-schema.
Then generated
satisfies the schema.
You can also use Options to specify generation rules that are not specified in the schema.