Official SDKs for validating JSON documents against JSON Structure schemas.
JSON Structure is a type-oriented schema language for JSON, designed for defining data structures that can be validated and mapped to programming language types.
| Language | Package | Status |
|---|---|---|
| Python | json-structure | ✅ Available |
| .NET | JsonStructure | ✅ Available |
| Java | json-structure | ✅ Available |
| TypeScript/JavaScript | @json-structure/sdk | ✅ Available |
| Go | github.com/json-structure/sdk/go | ✅ Available |
| Rust | json-structure | ✅ Available |
| Perl | JSON::Structure | ✅ Available |
| Swift | JSONStructure | ✅ Available |
| C | json-structure | ✅ Available |
| PHP | json-structure/sdk | ✅ Available |
| Ruby | jsonstructure | ✅ Available |
| R | jsonstructure | ✅ Available |
All SDKs provide:
- Schema Validation: Validate JSON Structure schema documents for correctness
- Instance Validation: Validate JSON instances against JSON Structure schemas
- Full Type Support: All 34 primitive and compound types from JSON Structure Core v0
- Extensions: Support for validation addins, conditional composition, and imports
A standalone command-line validator for quick schema and instance checks—no SDK wiring required.
Download from GitHub Releases:
| Platform | Architecture | File |
|---|---|---|
| Linux | x86_64 | jstruct-x86_64-unknown-linux-gnu.tar.gz |
| Linux | ARM64 | jstruct-aarch64-unknown-linux-gnu.tar.gz |
| macOS | Intel | jstruct-x86_64-apple-darwin.tar.gz |
| macOS | Apple Silicon | jstruct-aarch64-apple-darwin.tar.gz |
| Windows | x86_64 | jstruct-x86_64-pc-windows-msvc.zip |
| Windows | ARM64 | jstruct-aarch64-pc-windows-msvc.zip |
Note: The binaries are not code-signed. On Windows you may need to click "Run anyway" in SmartScreen; on macOS run
xattr -d com.apple.quarantine jstructafter extracting.
If you have Rust installed:
cargo install json-structure --features cli# Validate schema files
jstruct check schema.struct.json another.struct.json
# Validate instances against a schema (quiet—exit code only)
jstruct validate -q -s schema.struct.json data/*.jsonSee rust/CLI.md for the full command reference.
pip install json-structurefromjson_structureimportInstanceValidator, SchemaValidator# Validate a schemaschema= {
"$schema": "https://json-structure.org/meta/core/v0/#",
"name": "Person",
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "int32"}
}
}
schema_validator=SchemaValidator()
schema_errors=schema_validator.validate(schema)
# Validate an instanceinstance= {"name": "Alice", "age": 30}
instance_validator=InstanceValidator(schema)
instance_errors=instance_validator.validate_instance(instance)dotnet add package JsonStructureusingJsonStructure.Validation;usingSystem.Text.Json.Nodes;// Validate a schemavarschema=JsonNode.Parse("""{ "$schema": "https://json-structure.org/meta/core/v0/#", "name": "Person", "type": "object", "properties": { "name": {"type": "string"}, "age": {"type": "int32"} }}""");varschemaValidator=newSchemaValidator();varschemaResult=schemaValidator.Validate(schema);// Validate an instancevarinstance=JsonNode.Parse("""{"name": "Alice", "age": 30}""");varinstanceValidator=newInstanceValidator();varinstanceResult=instanceValidator.Validate(instance,schema);<dependency>
<groupId>org.json-structure</groupId>
<artifactId>json-structure</artifactId>
<version>0.1.0</version>
</dependency>importorg.json_structure.validation.*;
importcom.fasterxml.jackson.databind.JsonNode;
importcom.fasterxml.jackson.databind.ObjectMapper;
ObjectMappermapper = newObjectMapper();
// Validate a schemaJsonNodeschema = mapper.readTree("""{ "$schema": "https://json-structure.org/meta/core/v0/#", "name": "Person", "type": "object", "properties": { "name": {"type": "string"}, "age": {"type": "int32"} }}""");
SchemaValidatorschemaValidator = newSchemaValidator();
ValidationResultschemaResult = schemaValidator.validate(schema);
// Validate an instanceJsonNodeinstance = mapper.readTree("{\"name\": \"Alice\", \"age\": 30}");
InstanceValidatorinstanceValidator = newInstanceValidator();
ValidationResultinstanceResult = instanceValidator.validate(instance, schema);npm install @json-structure/sdkimport{SchemaValidator,InstanceValidator}from'@json-structure/sdk';// Validate a schemaconstschema={$schema: 'https://json-structure.org/meta/core/v0/#',name: 'Person',type: 'object',properties: {name: {type: 'string'},age: {type: 'int32'}}};constschemaValidator=newSchemaValidator();constschemaResult=schemaValidator.validate(schema);// Validate an instanceconstinstance={name: 'Alice',age: 30};constinstanceValidator=newInstanceValidator();constinstanceResult=instanceValidator.validate(instance,schema);go get github.com/json-structure/sdk/gopackage main
import (
"encoding/json""fmt"
jsonstructure "github.com/json-structure/sdk/go"
)
funcmain() {
// Define a schemaschemaJSON:=`{ "$schema": "https://json-structure.org/meta/core/v0/#", "name": "Person", "type": "object", "properties": { "name": {"type": "string"}, "age": {"type": "int32"} } }`varschemamap[string]interface{}
json.Unmarshal([]byte(schemaJSON), &schema)
// Validate the schemaschemaValidator:=jsonstructure.NewSchemaValidator(nil)
schemaResult:=schemaValidator.Validate(schema)
fmt.Printf("Schema valid: %v\n", schemaResult.IsValid)
// Validate an instanceinstance:=map[string]interface{}{
"name": "Alice",
"age": float64(30),
}
instanceValidator:=jsonstructure.NewInstanceValidator(nil)
instanceResult:=instanceValidator.Validate(instance, schema)
fmt.Printf("Instance valid: %v\n", instanceResult.IsValid)
}cpanm JSON::Structureuse JSON::Structure::SchemaValidator;
use JSON::Structure::InstanceValidator;
use JSON::MaybeXS;
# Define a schemamy$schema = decode_json(q|{ "$schema": "https://json-structure.org/meta/core/v0/#", "name": "Person", "type": "object", "properties": { "name": {"type": "string"}, "age": {"type": "int32"} }}|);
# Validate the schemamy$schema_validator = JSON::Structure::SchemaValidator->new();
my$schema_result = $schema_validator->validate($schema);
print"Schema valid: ", ($schema_result->is_valid ? "true" : "false"), "\n";
# Validate an instancemy$instance = decode_json('{"name": "Alice", "age": 30}');
my$instance_validator = JSON::Structure::InstanceValidator->new(schema=>$schema);
my$instance_result = $instance_validator->validate($instance);
print"Instance valid: ", ($instance_result->is_valid ? "true" : "false"), "\n";cargo add json-structureuse json_structure::{SchemaValidator,InstanceValidator};use serde_json::json;fnmain(){// Define a schemalet schema = json!({"$schema":"https://json-structure.org/meta/core/v0/#","name":"Person","type":"object","properties":{"name":{"type":"string"},"age":{"type":"int32"}}});// Validate the schemalet schema_validator = SchemaValidator::new();let schema_result = schema_validator.validate(&schema);println!("Schema valid: {}", schema_result.is_valid());// Validate an instancelet instance = json!({"name":"Alice","age":30});let instance_validator = InstanceValidator::new();let instance_result = instance_validator.validate(&instance,&schema);println!("Instance valid: {}", instance_result.is_valid());}# Build with CMake
mkdir build &&cd build
cmake ..
cmake --build .#include"json_structure.h"#include<stdio.h>intmain() {
// Define a schemaconstchar*schema_json="{\n""\"$schema\": \"https://json-structure.org/meta/core/v0/#\",\n""\"name\": \"Person\",\n""\"type\": \"object\",\n""\"properties\": {\n"" \"name\": {\"type\": \"string\"},\n"" \"age\": {\"type\": \"int32\"}\n""}\n""}";
// Parse and validate the schemacJSON*schema=cJSON_Parse(schema_json);
JsValidationResultresult=js_validate_schema(schema);
printf("Schema valid: %s\n", result.is_valid ? "true" : "false");
js_result_cleanup(&result);
// Validate an instanceconstchar*instance_json="{\"name\": \"Alice\", \"age\": 30}";
cJSON*instance=cJSON_Parse(instance_json);
result=js_validate_instance(instance, schema);
printf("Instance valid: %s\n", result.is_valid ? "true" : "false");
js_result_cleanup(&result);
cJSON_Delete(instance);
cJSON_Delete(schema);
return0;
}Add to your Package.swift:
dependencies:[.package(url:"https://github.com/json-structure/sdk.git", from:"0.1.0")]import JSONStructure
import Foundation
// Define a schema
letschema:[String:Any]=["$schema":"https://json-structure.org/meta/core/v0/#","$id":"https://example.com/person.struct.json","name":"Person","type":"object","properties":["name":["type":"string"],"age":["type":"int32"]]]
// Validate the schema
letschemaValidator=SchemaValidator()letschemaResult= schemaValidator.validate(schema)print("Schema valid: \(schemaResult.isEmpty)")
// Validate an instance
letinstance:[String:Any]=["name":"Alice","age":30]letinstanceValidator=InstanceValidator(schema: schema)letinstanceResult= instanceValidator.validate(instance)print("Instance valid: \(instanceResult.isEmpty)")composer require json-structure/sdk<?phpuseJsonStructure\SchemaValidator;
useJsonStructure\InstanceValidator;
// Validate a schema$schema = [
'$schema' => 'https://json-structure.org/meta/core/v0/#',
'$id' => 'https://example.com/person.struct.json',
'name' => 'Person',
'type' => 'object',
'properties' => [
'name' => ['type' => 'string'],
'age' => ['type' => 'int32']
]
];
$schemaValidator = newSchemaValidator();
$schemaErrors = $schemaValidator->validate($schema);
// Validate an instance$instance = ['name' => 'Alice', 'age' => 30];
$instanceValidator = newInstanceValidator($schema);
$instanceErrors = $instanceValidator->validate($instance);# install.packages("remotes")remotes::install_github("json-structure/sdk", subdir="r")library(jsonstructure)
# Validate a schema (accepts a JSON string or an R list)schema<-list(
"$schema"="https://json-structure.org/meta/core/v0/#",
name="Person",
type="object",
properties=list(
name=list(type="string"),
age=list(type="int32")
)
)
schema_result<- js_validate_schema(schema)
is_valid(schema_result)
# Validate an instanceinstance_result<- js_validate_instance(list(name="Alice", age=30L), schema)
is_valid(instance_result)Contributions are welcome! Please see the individual SDK directories for language-specific contribution guidelines.
MIT License - see LICENSE for details.