Generates C++ code from JSON-Schema
Project description
JSON-Schema Codegen
This python library consumes JSON-Schema and generates C++ code. It generates structures to hold the values defined in the schema, restricting the values according to the schema. Each structure has JSON serialization and de-serialization methods.
Supported Schema Features
Schemas (and sub-schemas) that are boolean or schemas without type
are not currently supported.
- type: string
- minLength
- maxLength
- pattern
- type: string with enum
- type: integer
- maximum
- minimum
- exclusiveMaximum
- exclusiveMinimum
- multipleOf
- type: number
- maximum
- minimum
- exclusiveMaximum
- exclusiveMinimum
- multipleOf
- type: boolean
- type: null
- type: array
- items
- minItems
- maxItems
- type: object
- properties
- required
- allOf
- anyOf
- oneOf
References
$ref
references are supported for array items, object properties, allOf, anyOf, and oneOf. However, the caller must provide a class which translates the reference into a class name and namespace.
Installation
pip install json-schema-codegen
Usage
See example_usage.py
for a more elaborate example.
import jsonschemacodegen.cpp as cpp
simpleResolver = cpp.SimpleResolver()
output_dir = "/tmp"
generator = cpp.GeneratorFromSchema(src_output_dir=output_dir,
header_output_dir=output_dir,
resolver=simpleResolver,
namespace=[],
src_usings=[])
sampleSchema = {"type": "string"}
generator.Generate(sampleSchema, 'Example', 'example')
License
GPLv2
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for json-schema-codegen-0.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c66edb48db597b4542d2ee1b9bc9d538c7490ce9bed2b612f226385512351a51 |
|
MD5 | b5bb651d1572c71d2d50be2bf762e14b |
|
BLAKE2b-256 | e9548865379a30bd9ed801fe67fd6b041dd66e1a75c77e669979737db2507533 |
Hashes for json_schema_codegen-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22bd30add49006bd3372319088ef3055575beec4c19b005acd3d74ba30c744b0 |
|
MD5 | 8fb3d2f3b9ca0359ba3bc69e7f221c9b |
|
BLAKE2b-256 | 596838498c6586154723f0d8ecad294944adb76eac1c98d438819097bad32a15 |