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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee988d3106731005873ec1809a11b9e1f8e8627e3acd3dfdd85a103dc510e4f3 |
|
MD5 | 3944149091407ab6098986b07471bb8d |
|
BLAKE2b-256 | 29b4a06a587603ca10f2fcb83dbb870966274bc39af97e365326b668e8621031 |
Hashes for json_schema_codegen-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fdd864356cab031253f43fbd7c8459a3d91fae0676984e1c7d9ee9e6a0ef287 |
|
MD5 | a9e5279b636fff7c06a58ee435c7689d |
|
BLAKE2b-256 | fab91366ef37f43b8103c2063ebcb5fdd006941fd5fca8177fbfbc942b959542 |