This document provides comprehensive guidelines for developing JSON Structure SDKs for new programming languages. All SDKs must conform to the JSON Structure specifications and pass the standardized conformance tests.
- Overview
- Specifications
- Required Components
- Type System
- Keywords Reference
- Error Codes
- Test Assets
- Schema Exporter (Optional)
- Conformance Checklist
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. Each SDK implementation must provide:
- Schema Validator - Validates JSON Structure schema documents for correctness
- Instance Validator - Validates JSON instances against JSON Structure schemas
- Error Codes - Standardized error codes matching
assets/error-messages.json - Source Location Tracking - Line/column tracking for error messages
- Schema Exporter (optional) - Generates schemas from native language types (only for languages with runtime introspection)
All SDKs must implement the following specifications:
- JSON Structure Core: draft-vasters-json-structure-core
- Source:
/core/draft-vasters-json-structure-core.md - Defines types, keywords, and validation rules
- Metaschema:
https://json-structure.org/meta/core/v0/#
- Source:
Extensions must be explicitly enabled via $uses keyword:
| Extension | Specification | Metaschema |
|---|---|---|
| Import | JSON Structure Import | Enables $import, $importdefs |
| Validation | JSON Structure Validation | Enables constraint keywords |
| Conditional Composition | JSON Structure Conditional Composition | Enables allOf, anyOf, oneOf, not, if/then/else |
| Alternate Names | JSON Structure Alternate Names | Enables altnames |
| Units | JSON Structure Units | Enables unit |
Validates that a JSON Structure schema document is syntactically and semantically correct.
Required functionality:
- Validate
$schema,$id,nameat root level - Validate all type declarations against allowed types
- Validate
$refreferences resolve to valid definitions - Validate keyword combinations are valid for declared types
- Validate constraint values are appropriate (e.g.,
minimum≤maximum) - Support recursive schema validation with cycle detection
- Track and report source locations (line/column) for errors
Reference implementations:
- .NET:
dotnet/src/JsonStructure/Validation/SchemaValidator.cs - Java:
java/src/main/java/org/json_structure/validation/SchemaValidator.java - Python:
python/src/json_structure/schema_validator.py - TypeScript:
typescript/src/schema-validator.ts - Go:
go/schema_validator.go
Validates JSON data instances against a JSON Structure schema.
Required functionality:
- Validate instances against all primitive types (see Type System)
- Validate instances against all compound types (
object,array,set,map,tuple,choice) - Validate
requiredproperties - Validate
additionalPropertiesconstraints - Validate type references (
$ref) - Validate
enumandconstconstraints - Support extension validation keywords when enabled via
$uses - Support conditional composition when enabled via
$uses - Track and report source locations (line/column) for errors
Reference implementations:
- .NET:
dotnet/src/JsonStructure/Validation/InstanceValidator.cs - Java:
java/src/main/java/org/json_structure/validation/InstanceValidator.java - Python:
python/src/json_structure/instance_validator.py - TypeScript:
typescript/src/instance-validator.ts - Go:
go/instance_validator.go
Provides line/column tracking for error messages.
Required functionality:
- Parse JSON and track positions of all nodes
- Map JSON Pointer paths to source locations
- Handle nested objects and arrays
- Return
(0, 0)for unknown locations
Reference implementations:
- .NET:
dotnet/src/JsonStructure/Validation/JsonSourceLocator.cs - Java:
java/src/main/java/org/json_structure/validation/JsonSourceLocator.java - Python:
python/src/json_structure/json_source_locator.py - TypeScript:
typescript/src/json-source-locator.ts - Go:
go/json_source_locator.go
Standardized error codes for consistent error reporting across all SDKs.
Reference file: assets/error-messages.json
Required implementation:
- Define constants for all error codes in
error-messages.json - Use exact code strings (e.g.,
"SCHEMA_TYPE_INVALID") - Support both
errorandwarningseverity levels - Include all parameters defined in the message templates
Reference implementations:
- .NET:
dotnet/src/JsonStructure/Validation/ErrorCodes.cs - Java:
java/src/main/java/org/json_structure/validation/ErrorCodes.java - Python:
python/src/json_structure/error_codes.py - TypeScript:
typescript/src/error-codes.ts - Go:
go/error_codes.go
All SDKs must support these primitive types from the JSON Structure Core specification:
| Type | JSON Representation | Description |
|---|---|---|
string |
JSON string | UTF-8 string |
boolean |
JSON boolean | true or false |
null |
JSON null | Null value |
| Type | JSON Representation | Range/Description |
|---|---|---|
number |
JSON number | Any JSON number |
integer |
JSON number | Alias for int32 |
int8 |
JSON number | -128 to 127 |
int16 |
JSON number | -32,768 to 32,767 |
int32 |
JSON number | -2³¹ to 2³¹-1 |
int64 |
JSON number | -2⁶³ to 2⁶³-1 |
int128 |
JSON number/string | -2¹²⁷ to 2¹²⁷-1 |
uint8 |
JSON number | 0 to 255 |
uint16 |
JSON number | 0 to 65,535 |
uint32 |
JSON number | 0 to 2³²-1 |
uint64 |
JSON number | 0 to 2⁶⁴-1 |
uint128 |
JSON number/string | 0 to 2¹²⁸-1 |
float |
JSON number | 32-bit IEEE 754 |
float8 |
JSON number | 8-bit float |
double |
JSON number | 64-bit IEEE 754 |
decimal |
JSON number/string | Arbitrary precision |
| Type | Format (RFC 3339) | Example |
|---|---|---|
date |
YYYY-MM-DD |
"2024-01-15" |
time |
HH:MM:SS[.sss] |
"14:30:00" |
datetime |
YYYY-MM-DDTHH:MM:SS[.sss]Z |
"2024-01-15T14:30:00Z" |
duration |
ISO 8601 duration | "P1Y2M3D" or "PT1H30M" |
| Type | Format | Description |
|---|---|---|
uuid |
RFC 9562 | "550e8400-e29b-41d4-a716-446655440000" |
uri |
RFC 3986 | "https://example.com/path" |
binary |
Base64 | Base64-encoded bytes |
jsonpointer |
RFC 6901 | "/foo/bar/0" |
| Type | Description | Required Keywords |
|---|---|---|
object |
JSON object with typed properties | properties |
array |
Homogeneous list | items |
set |
Unique homogeneous list | items (validates uniqueness) |
map |
Dictionary with string keys | values |
tuple |
Fixed-length typed array | properties + tuple |
choice |
Discriminated union | choices + selector |
any |
Any JSON value | (none) |
These keywords are defined in the JSON Structure Core specification:
$schema, $id, $ref, $root, $extends, $uses, $offers, $comment
definitions, name, abstract, type
properties, additionalProperties, required
items, values
tuple, choices, selector
enum, const, default
title, description, examples
precision, scale
The following keywords from JSON Schema are NOT valid in JSON Structure:
- ❌
$anchor- Not a JSON Structure keyword - ❌
$defs- Usedefinitionsinstead - ❌
prefixItems- Useproperties+tupleinstead - ❌
options- Usechoicesinstead - ❌
discriminator- Useselectorinstead - ❌
deprecated- Not a JSON Structure keyword
These keywords require $uses to declare the extension:
minLength, maxLength, pattern, format
minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf
minItems, maxItems, uniqueItems, contains, minContains, maxContains
minProperties, maxProperties, dependentRequired, propertyNames
contentEncoding, contentMediaType, contentCompression
allOf, anyOf, oneOf, not, if, then, else
$import, $importdefs
altnames
unit
All error codes are defined in assets/error-messages.json.
| Category | Prefix | Description |
|---|---|---|
| Schema | SCHEMA_* |
Schema validation errors |
| Instance | INSTANCE_* |
Instance validation errors |
| Code | Description |
|---|---|
SCHEMA_NULL |
Schema cannot be null |
SCHEMA_INVALID_TYPE |
Schema must be boolean or object |
SCHEMA_ROOT_MISSING_ID |
Root schema must have $id |
SCHEMA_ROOT_MISSING_NAME |
Root schema with type must have name |
SCHEMA_TYPE_INVALID |
Invalid type name |
SCHEMA_REF_NOT_FOUND |
$ref references undefined definition |
SCHEMA_TUPLE_MISSING_DEFINITION |
Tuple requires properties + tuple |
SCHEMA_CHOICE_MISSING_CHOICES |
Choice requires choices keyword |
SCHEMA_MAP_MISSING_VALUES |
Map requires values keyword |
| Code | Description |
|---|---|
INSTANCE_TYPE_MISMATCH |
Value does not match expected type |
INSTANCE_REQUIRED_MISSING |
Required property is missing |
INSTANCE_ADDITIONAL_PROPERTY |
Additional property not allowed |
INSTANCE_ENUM_MISMATCH |
Value not in enum |
INSTANCE_CONST_MISMATCH |
Value does not match const |
Located in test-assets/schemas/:
These schemas should fail validation:
| File | Tests |
|---|---|
allof-not-array.struct.json |
allOf must be array |
array-missing-items.struct.json |
Array requires items |
circular-ref-direct.struct.json |
Direct circular $ref |
enum-duplicates.struct.json |
Enum values must be unique |
enum-empty.struct.json |
Enum cannot be empty |
map-missing-values.struct.json |
Map requires values |
missing-type.struct.json |
Schema must have type |
ref-undefined.struct.json |
$ref must resolve |
tuple-missing-definition.struct.json |
Tuple requires definition |
unknown-type.struct.json |
Invalid type name |
Full list: test-assets/schemas/invalid/
These schemas should pass validation when extensions are enabled:
| File | Tests |
|---|---|
string-pattern-with-uses.struct.json |
Pattern validation |
numeric-minimum-with-uses.struct.json |
Numeric constraints |
array-contains-with-uses.struct.json |
Contains validation |
object-dependentrequired-with-uses.struct.json |
Dependent required |
Full list: test-assets/schemas/validation/
Located in test-assets/instances/:
Instance/schema pairs where validation should fail.
Instance/schema pairs where validation should pass.
The schema exporter generates JSON Structure schemas from native language types. This component is only applicable to languages that support runtime type introspection/reflection:
| Language | Introspection Mechanism | Implement Exporter |
|---|---|---|
| .NET/C# | Reflection, System.Text.Json metadata |
✅ Yes |
| Java | Reflection, Jackson annotations | ✅ Yes |
| Python | dataclasses, typing, inspect |
✅ Yes |
| TypeScript | Decorators (limited, compile-time) | |
| Go | reflect package |
✅ Yes |
| Rust | (compile-time macros only) | ❌ No |
| C/C++ | (no runtime reflection) | ❌ No |
When implementing a schema exporter:
-
Type Mapping - Map native types to JSON Structure types:
string→stringint,int32→int32long,int64→int64float→floatdouble→doublebool→booleanDateTime→datetimeUUID/Guid→uuidList<T>→arraywithitemsSet<T>→setwithitemsDict<K,V>→mapwithvalues- Classes/structs →
objectwithproperties
-
Metadata Extraction - Extract from:
- Property names (respecting serialization attributes)
- Documentation comments/docstrings
- Validation attributes (when extended mode enabled)
- Nullability information for
required
-
Options - Support configuration:
schemaUri- The$schemavalueincludeSchemaKeyword- Whether to emit$schemaincludeTitles- Whether to emittitleincludeDescriptions- Whether to emitdescriptionuseExtendedValidation- Enable validation keywords
Reference implementations:
- .NET:
dotnet/src/JsonStructure/Schema/JsonStructureSchemaExporter.cs - Java:
java/src/main/java/org/json_structure/schema/JsonStructureSchemaExporter.java - Python:
python/src/json_structure/schema_exporter.py
Use this checklist to verify a new SDK implementation meets all requirements.
- Validates
$schemakeyword (must be valid JSON Structure metaschema URI) - Validates
$idis required at root level - Validates
nameis required whentypeis present at root - Validates all primitive types (34 types)
- Validates all compound types (
object,array,set,map,tuple,choice,any) - Validates
$refreferences resolve to existing definitions - Validates
definitionsentries havetypeor$ref - Validates
propertiesis an object - Validates
requiredis an array of strings - Validates
requiredproperties exist inproperties - Validates
itemsis required forarrayandsettypes - Validates
valuesis required formaptype - Validates
tuplerequirespropertiesandtuplekeywords - Validates
choicerequireschoicesand optionallyselector - Validates
enumis a non-empty array with unique values - Validates
constis a valid JSON value - Validates constraint combinations (e.g.,
minimum≤maximum) - Detects circular
$refreferences - Reports source locations (line/column) for all errors
- Uses standardized error codes from
error-messages.json
- Validates all 34 primitive types with correct format checking
- Validates
objectinstances againstproperties - Validates
requiredproperties are present - Rejects unknown properties when
additionalProperties: false - Validates
arrayinstances againstitemsschema - Validates
setinstances for uniqueness - Validates
mapinstances againstvaluesschema - Validates
tupleinstances matchproperties+tupleorder - Validates
choiceinstances withselectorandchoices - Validates
enumvalues match exactly - Validates
constvalues match exactly - Resolves
$refreferences during validation - Reports source locations (line/column) for all errors
- Uses standardized error codes from
error-messages.json
- Validates
$usesdeclares extensions correctly - Validates
$offersdeclares extensions correctly - Supports
$importand$importdefs(Import extension) - Supports conditional composition (
allOf,anyOf,oneOf,not,if/then/else) - Supports validation constraints when
JSONStructureValidationenabled - Supports
altnameswhenJSONStructureAlternateNamesenabled - Supports
unitwhenJSONStructureUnitsenabled
- Does NOT accept
$anchoras a keyword - Does NOT accept
$defs(usesdefinitions) - Does NOT accept
prefixItems(usesproperties+tuple) - Does NOT accept
options(useschoices) - Does NOT accept
discriminator(usesselector) - Does NOT accept
deprecatedas a keyword
-
tupleusesproperties+tuplearray (notprefixItems) -
choiceusesselector+choices(notdiscriminator+options) -
definitions(not$defs)
- All error codes match
assets/error-messages.json - Error messages include path information (JSON Pointer)
- Error messages include source location when available
- Errors distinguish between
errorandwarningseverity - Errors are collected (validation continues after first error)
- All schemas in
test-assets/schemas/invalid/fail validation - All schemas in
test-assets/schemas/validation/pass with extensions enabled - All instance tests in
test-assets/instances/produce expected results - Unit tests cover all type validations
- Unit tests cover all error conditions
- README.md with installation and usage examples
- API documentation for all public classes/functions
- Examples for schema validation
- Examples for instance validation
- Examples for schema export (if applicable)
- Package published to language-appropriate registry
- Semantic versioning
- MIT license
- Changelog maintained
-
Create directory structure:
sdk/<language>/ ├── README.md ├── src/ │ ├── schema_validator.* │ ├── instance_validator.* │ ├── error_codes.* │ ├── json_source_locator.* │ ├── types.* │ └── schema_exporter.* (optional) └── tests/ -
Implement components in order:
- Types/ValidationResult
- Error codes (from
assets/error-messages.json) - JSON source locator
- Schema validator
- Instance validator
- Schema exporter (if applicable)
-
Run conformance tests against
test-assets/ -
Complete checklist above
-
Submit PR with:
- Full implementation
- Test coverage report
- Documentation
- Completed conformance checklist