Skip to main content

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


$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.


pip install json-schema-codegen


See for a more elaborate example.

import jsonschemacodegen.cpp as cpp

simpleResolver = cpp.SimpleResolver()
output_dir = "/tmp"

generator = cpp.GeneratorFromSchema(src_output_dir=output_dir,

sampleSchema = {"type": "string"}

generator.Generate(sampleSchema, 'Example', 'example')



Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for json-schema-codegen, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size json_schema_codegen-0.0.3-py3-none-any.whl (30.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size json-schema-codegen-0.0.3.tar.gz (12.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page