JSON Schema for the enterprise
This document specifies the JSON Schema Definition Language, which allows for the description of the structure and to constrain the contents of JSON documents. The schema language is represented in two different but equally translatable vocabularies: a JSON vocabulary, and an XML vocabulary. The schema language extends the capabilities found in JSON documents.
1 Introduction
1.1 Dependencies on Other Specifications
1.2 Conventions Used in This Document
2 Purpose
3 Requirements
4 Specification
4.1 Schema Document
4.2 Constraint Types
4.2.1 boolean
4.2.2 number
4.2.2.1 number.scale
4.2.2.2 number.range
4.2.3 string
4.2.3.1 string.pattern
4.2.4 object
4.2.4.1 object.properties
4.2.4.2 Property Names
4.2.4.3 object.abstract
4.2.4.4 object.extends
4.2.4.4.1 Type Declarations
4.2.4.4.2 Object Properties
4.2.5 array
4.2.5.1 array.elements
4.2.5.2 array.minIterate
and array.maxIterate
4.2.6 reference
4.2.6.1 reference.type
4.2.6.1.1 Object Properties
4.2.6.1.2 Array Elements
4.2.7 any
4.2.7.1 any.types
4.2.7.1.1 Object Properties
4.2.7.1.2 Array Elements
4.3 Type Declarations
4.4 Object Properties
4.5 Array Elements
4.6 Language specific bindings
4.6.1 Type Bindings
4.6.2 Field Bindings
4.6.3 Type/Field Bindings
4.6.4 Examples
5 Related Resources for JSON Schema
5.1 Schemas for JSON Schema
5.1.1 Development
5.1.2 Current
5.1.3 Obsolete
6 Sample Schemas
6.1 structure.jsdx
6.2 structure.jsd
6.3 datatype.jsdx
6.4 datatype.jsd
6.5 binding.jsdx
6.6 binding.jsd
7 Contributing
8 Special Thanks
9 License
This document sets out the structural part of the JSON Schema Definition Language. It also contains a directory of links to these related resources.
The JSON Schema Definition Language is designed to describe JSON documents by using schema components to constrain and document the meaning, usage and relationships of their constituent parts: value types and their content. Schemas may also provide for the specification of additional document information, such as normalization and defaulting of values. Schemas have facilities for self-documentation. Thus, the JSON Schema Definition Language can be used to define, describe and catalogue JSON vocabularies for JSON documents.
Any application that consumes well-formed JSON can use the JSON Schema Definition Language formalism to express syntactic, structural and value constraints applicable to its document instances. The JSON Schema Definition Language formalism allows a useful level of constraint checking to be described and implemented for a wide spectrum of JSON applications. However, the language defined by this specification does not attempt to provide all the facilities that might be needed by any application. Some applications may require constraint capabilities not expressible in this language, and so may need to perform their own additional validations.
The definition of the JSON Schema Definition Language depends on the following specifications: RFC4627❐, RFC7159❐, and XMLSchema❐.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC2119.
Provide a schema language to describe normative contracts between producer and consumer ends of a protocol exchanging JSON documents.
-
The schema language MUST constrain and document the meaning, usage, constraints and relationships of the constituent parts of a JSON document.
-
The schema language MUST provide meaningful and useful constraint rules for the 5 JSON value types:
boolean
,number
,string
,object
, andarray
. -
The schema language MUST support schema descriptions for any and all legal JSON documents, as specified by RFC2119.
-
The schema language MUST be free-of and agnostic-to patterns specific to any particular programming language.
-
The schema language MUST be able to describe itself.
The JSON Schema Definition Language (JSD) is normatively defined in an XML Schema Document, with translations expressed in the JSON/XML Schema Definition Language (JSDx), as well as the JSON Schema Definition Language (JSD) itself.
The JSDx format offers XML validation, and using an XML IDE like oXygen XML Editor❐ offers edit-time XML validation, such as:
When using the JSDx format with the oXygen XML Editor❐, the auto-completion features of the editor will guide you in writing the schema. With the JSDx format, the XML editor will also validate keys and keyrefs to ensure that declared types are referenced correctly.
The JSD is comprised of 5 structural abstractions:
4.1 Schema Document
4.2 Constraint Types
4.2.1 boolean
4.2.2 number
4.2.2.1 number.scale
4.2.2.2 number.range
4.2.3 string
4.2.3.1 string.pattern
4.2.4 object
4.2.4.1 object.properties
4.2.4.2 Property Names
4.2.4.3 object.abstract
4.2.4.4 object.extends
4.2.4.4.1 Type Declarations
4.2.4.4.2 Object Properties
4.2.5 array
4.2.5.1 array.elements
4.2.5.2 array.minIterate
and array.maxIterate
4.2.6 reference
4.2.6.1 reference.type
4.2.6.1.1 Object Properties
4.2.6.1.2 Array Elements
4.2.7 any
4.2.7.1 any.types
4.2.7.1.1 Object Properties
4.2.7.1.2 Array Elements
4.3 Type Declarations
4.4 Object Properties
4.5 Array Elements
4.6 Language specific bindings
4.6.1 Type Bindings
4.6.2 Field Bindings
4.6.3 Type/Field Bindings
4.6.4 Examples
The schema is the root object of the JSD, and contains type definitions.
Property Name | Property Value | |
---|---|---|
( schema ) |
jx:ns jx:schemaLocation jx:targetNamespace doc [a-zA-Z_$][-a-zA-Z\d_$]* |
Namespace of the JSON Schema. Required. Used by schema processors to determine to which version of the JSON Schema the JSD is written. Location URL of namespace. Optional. Specified as: "%NAMESPACE_URI% %LOCATION_URL%" Used by schema processors to determine location of schema definition for a namespace. Target namespace of schema document. Optional. Specified as: "%NAMESPACE_URI%" Represents the namespace of elements declared within the schema document. Text comments. Optional. Type Declaration. Optional. Root object definitions that are referenceable throughout the schema. |
{
"jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
"jx:schemaLocation": "http://www.jsonx.org/schema-0.4.jsd http://www.jsonx.org/schema.jsd",
"jx:targetNamespace": "https://www.jsonx.org/example.jsd"
...
}
<schema
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd">
targetNamespace="https://www.jsonx.org/example.jsdx">
...
</schema>
The Constraint Types define the constraint properties for the five JSON value types: boolean, number, string, object, and array. Aditionally, the JSON Schema Definition Language defines two meta Constraint Types named any and reference.
The JSD has 3 different scopes where Constraint Types can be defined, which provide different sets of their own constraint properties that apply to all Constraint Types:
Each Constraint Type supports the doc
attribute.
Property Name | Property Value | |
---|---|---|
( boolean | number | string | object | array | any | reference ) |
doc |
Text comments. Optional. |
{ "doc": "Comment for this element",
...
}
<any doc="Comment for this element">
...
</any>
The boolean type is used for the boolean values: true
and false
.
The boolean type does not have validation constraints.
Property Name | Property Value | |
---|---|---|
( boolean ) |
jx:type bindings |
boolean Bindings declaration Specifies the language specific bindings. |
Usage for type declarations, object properties, and array elements:
{ "jx:type": "boolean" }
Usage for type declarations and array elements:
<boolean/>
Usage for object properties:
<property xsi:type="boolean"/>
Examples
Value | Pass | Description |
---|---|---|
true |
✅ | The value true . |
false |
✅ | The value false . |
TRUE |
❌ | TRUE is not a valid boolean type. |
FALSE |
❌ | FALSE is not a valid boolean type. |
0 |
❌ | 0 is not a valid boolean type. |
1 |
❌ | 1 is not a valid boolean type. |
"true" |
❌ | Boolean as string. |
Used for any numeric type, either integers or floating point numbers.
The number type defines two constraint properties for number JSON value type: scale, and range.
Property Name | Property Value | |
---|---|---|
( number ) |
jx:type scale range bindings |
number (0|1|2|...) The number of digits to the right of the decimal point. If a value is not specified, the scale is unbounded. Numerical range Specifies the minimum and maximum limits in interval notation❐. Bindings declaration Specifies the language specific bindings. |
Usage for type declarations, object properties, and array elements:
{ "jx:type": "number" }
Usage for type declarations and array elements:
<number/>
Usage for object properties:
<property xsi:type="number"/>
Examples
Value | Pass | Description |
---|---|---|
5 |
✅ | Integer. |
-7.12 |
✅ | Floating point number. |
12.332794E-5 |
✅ | Exponential notation. |
"7" |
❌ | Number as string. |
The scale
property specifies the maximum number of accepted digits after the decimal point.
A scale
of 3
represents a number with a maximum of 3 digits after the decimal.
A scale
of 0
represents an integer.
Usage for type declarations, object properties, and array elements:
{ "jx:type": "number", "scale": 2 }
Usage for type declarations and array elements:
<number scale="2"/>
Usage for object properties:
<property xsi:type="number" scale="2"/>
Examples
Value | Pass | Description |
---|---|---|
5.12 |
✅ | Floating point number with 2 digits after the decimal point. |
9.2E-1 |
✅ | Exponential notation representing a number with 2 digits after the decimal point. |
-0.1 |
✅ | Floating point number with 1 digit after the decimal point. |
8.123 |
❌ | Floating point number with 3 digits after the decimal point. |
8.3E-2 |
❌ | Exponential notation representing a number with 3 digits after the decimal point. |
"7.65" |
❌ | Number as string. |
The range
property specifies the numerical range (min and max) of accepted values in interval notation❐.
A range
of [0,10]
represents a number between 0
(inclusive) and 10
(inclusive).
A range
of (0,10)
represents a number between 0
(exclusive) and 10
(exclusive).
A range
of (1.2E1,)
represents a number greater than 1.2E1
(exclusive).
A range
of (,-9.8]
represents a number less than 9.8
(inclusive).
Usage for type declarations, object properties, and array elements:
{ "jx:type": "number", "range": "[-2,7.5)" }
Usage for type declarations and array elements:
<number range="[-2,7.5)"/>
Usage for object properties:
<property xsi:type="number" range="[-2,7.5)"/>
Examples
Value | Pass | Description |
---|---|---|
5.12 |
✅ | Floating point number between -2 (inclusive) and 7.5 (exclusive). |
0.3E1 |
✅ | Exponential notation representing a number between -2 (inclusive) and 7.5 (exclusive). |
-2 |
✅ | Integer between -2 (inclusive) and 7.5 (exclusive). |
7.49999999999 |
✅ | Floating point number between -2 (inclusive) and 7.5 (exclusive). |
-2.0000000001 |
❌ | Floating point number less than -2 (inclusive). |
7.5 |
❌ | Floating point number greater than 7.5 (exclusive). |
"6.65" |
❌ | Number as string. |
The string type is used for strings of text. It may contain Unicode characters.
The string type defines one constraint property for string JSON value type: pattern.
Property Name | Property Value | |
---|---|---|
( string ) |
jx:type pattern bindings |
string Regular expression Specifies the regular expression. Bindings declaration Specifies the language specific bindings. |
Usage for type declarations, object properties, and array elements:
{ "jx:type": "string" }
Usage for type declarations and array elements:
<string/>
Usage for object properties:
<property xsi:type="string"/>
Examples
Value | Pass | Description |
---|---|---|
"Déjà vu" |
✅ | String with unicode. |
"D\u00e9j\u00e0 vu" |
✅ | String with escaped unicode. |
"" |
✅ | Empty string. |
"42" |
✅ | String representing a number. |
42 |
❌ | A number. |
The pattern
property is used to restrict a string to a particular regular expression, as defined in JavaScript (ECMA 262❐).
A pattern
of ^[a-z]+$
represents a string of one or more lowercase latin characters.
A pattern
of ^.{12}$
represents a string of any 12 characters.
A pattern
of ^(\(\d{3}\) )?\d{3}-\d{4}$
represents a string matching a US phone number.
Usage for type declarations, object properties, and array elements:
{ "jx:type": "string", "pattern": "^(\\(\\d{3}\\) )?\\d{3}-\\d{4}$" }
Usage for type declarations and array elements:
<string pattern="^(\\(\\d{3}\\) )?\\d{3}-\\d{4}$"/>
Usage for object properties:
<property xsi:type="string" pattern="^(\\(\\d{3}\\) )?\\d{3}-\\d{4}$"/>
Examples
Value | Pass | Description |
---|---|---|
"(800) 356-9377" |
✅ | String with a 10 digit phone number. |
"356-9377" |
✅ | String with a 7 digit phone number. |
"(888) 356-9377 ext. 111" |
❌ | Unmatched "ext. 111". |
"(800) FLO-WERS" |
❌ | Phone number with letters. |
"" |
❌ | Empty string. |
The object type is used for mapping "keys" to "values".
The object type defines three constraint properties for object JSON value type: abstract, extends, and named properties.
Property Name | Property Value | |
---|---|---|
( object ) |
jx:type properties abstract extends |
object Property declarations Map of object properties. (true|false) Whether the object is not allowed to be instantiated. Name [( object ) type]#object Name of root-level object type declaration specifying object inheritence. |
The default object is not very useful, because it has no property mappings.
Usage for type declarations, object properties, and array elements:
{ "jx:type": "object" }
Usage for type declarations and array elements:
<object/>
Usage for object properties:
<property xsi:type="object"/>
Examples
Value | Pass | Description |
---|---|---|
{} |
✅ | An object without properties. |
{"foo":"bar"} |
❌ | An object with property "foo" mapping to value "bar". |
The properties
property specifies a map of accepted properties for the object.
Keys in the properties
map are considered as regular expressions (for more info, see Property Names).
Values in the properties
map are objects specifying accepted constraint types.
Usage for type declarations, object properties, and array elements:
{ "jx:type": "object", "properties": {
"foo": { "jx:type": "string", "pattern": "^[a-z]{,3}$", "nullable": true, "use": "optional" } }
}
Usage for type declarations and array elements:
<object>
<property name="foo" xsi:type="string" pattern="^[a-z]{,3}$" nullable="true" use="optional"/>
</object>
Usage for object properties:
<property xsi:type="object">
<property name="foo" xsi:type="string" pattern="^[a-z]{,3}$" nullable="true" use="optional"/>
</property>
Examples
Value | Pass | Description |
---|---|---|
{"foo":"bar"} |
✅ | An object with property "foo" mapping to value "bar". |
{"foo":""} |
✅ | An object with property "foo" mapping to empty string. |
{} |
✅ | An object without properties is ok, because "foo" is optional. |
{"foo":null} |
✅ | An object with property "foo" mapping to null is ok, because "foo" is nullable. |
{"foo":false} |
❌ | An object with property "foo" mapping to false . |
{"other":""} |
❌ | An object with property "other" mapping to empty string. |
Names of object properties are considered as regular expressions. If an object declaration defines a property with the name "[a-z]+", it means that this name matches any property whose name is one or more alpha characters. This also means that the name "foo" will only match "foo". If an object defines a property with a regular expression name that matches more than 1 string, the object will accept all the matching names (i.e. an object with multiple properties that match a single property definition with a regular expression name will be valid). If, however, there are multiple defined properties with regular expression name patterns that capture the same name, an associated value will be validated against the first matching property definition. The example below shows an any property that matches all names. Such a definition of an object type will match any object, except for {}
(because at least one any property is required).
Usage for type declarations, object properties, and array elements:
{ "jx:type": "object", "properties": {
".*": { "jx:type": "any" } }
}
Usage for type declarations and array elements:
<object>
<property name=".*" xsi:type="any"/>
</object>
Usage for object properties:
<property xsi:type="object">
<property name=".*" xsi:type="any"/>
</property>
Examples
Value | Pass | Description |
---|---|---|
{"foo":"bar"} |
✅ | Any property is valid. |
{"foo":"bar","wow":true} |
✅ | Any property is valid. |
{"foo":"bar","wow":true,"cool":42} |
✅ | Any property is valid. |
{} |
❌ | At least one any property is required. |
The abstract
property specifies whether the declared object is allowed to represent a value instance.
If abstract
is true, a value of the declared type is allowed to exits.
If abstract
is false, the declared type can only be used as a super-type of another object type declaration specifying the extends
property that links to the name of the abstract type.
The abstract
property is only allowed to appear on type declarations.
Usage for type declarations:
{ "myAbstractObject":
{ "jx:type": "object", "abstract": true, "properties": {
"foo": { "jx:type": "string", "pattern": "^[a-z]{,3}$", "nullable": true, "use": "optional" } } }
}
Usage for type declarations:
<object name="myAbstractObject" abstract="true">
<property name="foo" xsi:type="string" pattern="^[a-z]{,3}$" nullable="true" use="optional"/>
</object>
Examples
Value | Pass | Description |
---|---|---|
{"foo":"bar"} |
❌ | Instances of myAbstractObject are not allowed.Refer to extends property below. |
The extends
property accepts a name of an object type declaration, which specifies object inheritence.
The extends
property can only specify names of object type declarations.
The extends
property can specify names of object type declarations that are abstract
, or not.
Usage for type declarations:
{ "myAbstractObject":
{ "jx:type": "object", "abstract": true, "properties": {
"foo": { "jx:type": "string", "pattern": "^[a-z]{,3}$", "nullable": true, "use": "optional" } } },
"myRealObject":
{ "jx:type": "object", "extends": "myAbstractObject", "properties": {
"thisIsCool": { "jx:type": "boolean", "nullable": false } } }
}
Usage for type declarations:
<object name="myAbstractObject" abstract="true">
<property name="foo" xsi:type="string" pattern="^[a-z]{,3}$" nullable="true" use="optional"/>
</object>
<object name="myRealObject" extends="myAbstractObject">
<property name="thisIsCool" xsi:type="boolean" nullable="false"/>
</object>
Examples
Value | Pass | Description |
---|---|---|
{"foo":"bar"} |
✅ | An instance of myRealObject object with property "foo" mapping to value "bar". |
{"foo":"bar","thisIsCool":true} |
✅ | An instance of myRealObject object with property "foo" mapping to value "bar", and "thisIsCool" to true. |
{"foo":""} |
✅ | An instance of myRealObject object with property "foo" mapping to empty string. |
{"thisIsCool":true} |
✅ | An instance of myRealObject object with property "thisIsCool" mapping to true. |
{"thisIsCool":null} |
❌ | The property "thisIsCool" is not nullable. |
Usage for object properties:
{ "myAbstractObject":
{ "jx:type": "object", "abstract": true, "properties": {
"foo": { "jx:type": "string", "pattern": "^[a-z]{,3}$", "nullable": true, "use": "optional" } } },
"rootObject":
{ "jx:type": "object", "abstract": true, "properties": {
"myRealObject":
{ "jx:type": "object", "extends": "myAbstractObject", "properties": {
"thisIsCool": { "jx:type": "boolean", "nullable": false } } }
}
Usage for object properties:
<object name="myAbstractObject" abstract="true">
<property name="foo" xsi:type="string" pattern="^[a-z]{,3}$" nullable="true" use="optional"/>
</object>
<object name="rootObject">
<property xsi:type="object" extends="myAbstractObject">
<property name="thisIsCool" xsi:type="boolean" nullable="false"/>
</property>
</object>
Examples
Value | Pass | Description |
---|---|---|
{"myRealObject": {"foo":"bar"}} |
✅ | A rootObject object with an instance of myRealObject object with property "foo" mapping to value "bar". |
{"myRealObject": {"foo":"bar","thisIsCool":true}} |
✅ | A rootObject object with an instance of myRealObject object with property "foo" mapping to value "bar", and "thisIsCool" to true. |
{"myRealObject": {"foo":""}} |
✅ | A rootObject object with an instance of myRealObject object with property "foo" mapping to empty string. |
{"myRealObject": {"thisIsCool":true}} |
✅ | A rootObject object with an instance of myRealObject object with property "thisIsCool" mapping to true. |
{"myRealObject": {"thisIsCool":null}} |
❌ | The property "thisIsCool" is not nullable. |
{"thisIsCool":null} |
❌ | The rootObject does not declare the "thisIsCool" property. |
The array type is used for ordered member elements.
The array type defines three constraint properties for array JSON value type: minIterate, maxIterate, and member elements.
Property Name | Property Value | |
---|---|---|
( array ) |
jx:type elements minIterate maxIterate |
array [ Element declaration , ...] Array of member element declarations. (1|2|...) Specifies the minimum inclusive number of iterations of child member elements. (1|2|...|unbounded) Specifies the maximum inclusive number of iterations of child member elements. |
The default array is not very useful, because it has no member elements.
Usage for type declarations, object properties, and array elements:
{ "jx:type": "array" }
Usage for type declarations and array elements:
<array/>
Usage for object properties:
<property xsi:type="array"/>
Examples
Value | Pass | Description |
---|---|---|
[] |
✅ | An array without member elements. |
[null] |
❌ | An array with one null element. |
The elements
property specifies a list of accepted member elements.
Usage for type declarations, object properties, and array elements:
{ "jx:type": "array", "elements": [
{ "jx:type": "boolean", "minOccurs": "0", "maxOccurs": "1" },
{ "jx:type": "string", "minOccurs": "1", "maxOccurs": "2" } ]
}
Usage for type declarations and array elements:
<array>
<boolean minOccurs="0" maxOccurs="1"/>
<string minOccurs="1" maxOccurs="2"/>
</array>
Usage for object properties:
<property xsi:type="array">
<boolean minOccurs="0" maxOccurs="1"/>
<string minOccurs="1" maxOccurs="2"/>
</property>
Examples
Value | Pass | Description |
---|---|---|
[true, "hello"] |
✅ | An array with one boolean element, and one string element. |
["hello"] |
✅ | An array with only one string element, since zero boolean elements is allowed. |
["hello", "world"] |
✅ | An array with only two string elements, since zero boolean elements is allowed. |
["hello", "world", "again"] |
❌ | A maximum of 2 string elements is allowed. |
[true, "hello", "world"] |
✅ | An array with one boolean element and two string elements. |
[true, false, "hello"] |
❌ | A maximum of 1 boolean elements is allowed. |
[true] |
❌ | A minimum of 1 string elements are required. |
["hello", true] |
❌ | The boolean element must precede the string element. |
[] |
❌ | At least one string element is required. |
The minIterate
and maxIterate
properties specify the cardinality of allowed iterations (repetitions) of the member elements.
By default, both minIterate
and maxIterate
are 1
, which allows a single iteration of the specified member elements.
If minIterate
is 0
, an empty array is valid regardless of the member elements specified.
If maxIterate
is n
, the sequence of member elements can repeat n
times.
Usage for type declarations, object properties, and array elements:
{ "jx:type": "array", "minIterate": "0", "maxIterate": "2", "elements": [
{ "jx:type": "boolean", "minOccurs": "0", "maxOccurs": "1" },
{ "jx:type": "string", "minOccurs": "1", "maxOccurs": "2" } ]
}
Usage for type declarations and array elements:
<array minIterate="0" maxIterate="2">
<boolean minOccurs="0" maxOccurs="1"/>
<string minOccurs="1" maxOccurs="2"/>
</array>
Usage for object properties:
<property xsi:type="array" minIterate="0" maxIterate="2">
<boolean minOccurs="0" maxOccurs="1"/>
<string minOccurs="1" maxOccurs="2"/>
</property>
Examples
Value | Pass | Description |
---|---|---|
[true, "hello"] |
✅ | An array with one boolean element, and one string element. |
["hello"] |
✅ | An array with only one string element, since zero boolean elements is allowed. |
["hello", "world"] |
✅ | An array with only two string elements, since zero boolean elements is allowed. |
["hello", "world", "again"] |
✅ | The 3rd string element satisfies the 2nd iteration. |
["hello", "world", "again", "and", "again"] |
❌ | The 5th string element would require 3 iterations, but maxIterate is 2 . |
[true, "hello", "world", true, "and", "again"] |
✅ | An array with two full iterations. |
[true, false, "hello"] |
❌ | A maximum of 1 boolean elements is allowed to appear before a required string element. |
[true] |
❌ | A minimum of 1 string elements are required. |
["hello", true, "world"] |
✅ | The boolean element and "world" satisfy the 2nd iteration. |
[] |
✅ | An empty array is allowed due to minIterate set to 0 . |
The reference type defines one validation constraint: type.
Property Name | Property Value | |
---|---|---|
( reference ) |
jx:type type bindings |
reference Name of type declaration Name of root-level type declaration to reference. Bindings declaration Specifies the language specific bindings. |
The reference type is used to restrict content by specifying a single type declaration reference.
The reference type is only allowed to appear as an object property or an array member.
The type
property specifies the accepted type declaration.
Usage for type declarations, object properties, and array elements:
{ "jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
"myNumber": { "jx:type": "number" },
"myObject": { "jx:type": "object", "properties": {
"numOrStr": { "jx:type": "reference", "type": "myNumber" } } }
}
Usage for object properties:
<schema xmlns="http://www.jsonx.org/schema-0.4.xsd">
<number name="myNumber"/>
<object name="myArray">
<property name="numOrStr" xsi:type="reference" type="myNumber"/>
</object>
</schema>
Examples
Value | Pass | Description |
---|---|---|
{"numOrStr":5.2} |
✅ | A number is allowed. |
{"numOrStr":"hello"} |
❌ | A string is not allowed. |
{"numOrStr":false} |
❌ | A boolean is not allowed. |
{} |
❌ | The numOrStr property is required (by default, all properties specify use=required ). |
Usage for type declarations, object properties, and array elements:
{ "jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
"myNumber": { "jx:type": "number" },
"myArray": { "jx:type": "array", "elements": [
{ "jx:type": "reference", "type": "myNumber" } ] }
}
Usage for array elements:
<schema xmlns="http://www.jsonx.org/schema-0.4.xsd">
<number name="myNumber"/>
<array name="myArray">
<reference type="myNumber"/>
</string>
</schema>
Examples
Value | Pass | Description |
---|---|---|
[5.2] |
✅ | A number is allowed. |
["hello"] |
❌ | A string is not allowed. |
[false] |
❌ | A boolean is not allowed. |
[] |
❌ | The any element is required (by default, all array elements specify minOccurs=1 ). |
[5.2,6,4,2] |
✅ | Repeating occurrences of myNumber are allowed (by default, all array elements specify maxOccurs=unbounded) . |
The any type is used to restrict content by specifying a list of accepted type declarations, or an empty list for wildcard.
The any type is only allowed to appear as an object property or an array member.
The any type defines one validation constraint: types.
Property Name | Property Value | |
---|---|---|
( any ) |
jx:type types |
any [ Name of type declaration , ...] Array of type declarations. |
Usage for type declarations, object properties, and array elements:
{ "jx:type": "any" }
Usage for array elements:
<any/>
Usage for object properties:
<property xsi:type="any"/>
Examples
Value | Pass | Description |
---|---|---|
true |
✅ | Any constraint type is allowed. |
"hello" |
✅ | Any constraint type is allowed. |
4.53 |
✅ | Any constraint type is allowed. |
{"foo":"bar"} |
✅ | Any constraint type is allowed. |
[true,"world"] |
✅ | Any constraint type is allowed. |
[] |
✅ | Any constraint type is allowed. |
The types
property specifies accepted type declarations.
Usage for type declarations, object properties, and array elements:
{ "jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
"myNumber": { "jx:type": "number" },
"myString": { "jx:type": "string" },
"myObject": { "jx:type": "object", "properties": {
"numOrStr": { "jx:type": "any", "types": "myNumber myString" } } }
}
Usage for object properties:
<schema xmlns="http://www.jsonx.org/schema-0.4.xsd">
<number name="myNumber"/>
<string name="myString"/>
<object name="myArray">
<property name="numOrStr" xsi:type="any" types="myNumber myArray"/>
</object>
</schema>
Examples
Value | Pass | Description |
---|---|---|
{"numOrStr":5.2} |
✅ | A number is allowed. |
{"numOrStr":"hello"} |
✅ | A string is allowed. |
{"numOrStr":false} |
❌ | A boolean is not allowed. |
{} |
❌ | The numOrStr property is required (by default, all properties specify use=required ). |
Usage for type declarations, object properties, and array elements:
{ "jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
"myNumber": { "jx:type": "number" },
"myString": { "jx:type": "string" },
"myArray": { "jx:type": "array", "elements": [
{ "jx:type": "any", "types": "myNumber myString" } ] }
}
Usage for array elements:
<schema xmlns="http://www.jsonx.org/schema-0.4.xsd">
<number name="myNumber"/>
<string name="myString"/>
<array name="myArray">
<any types="myNumber myArray"/>
</string>
</schema>
Examples
Value | Pass | Description |
---|---|---|
[5.2] |
✅ | A number is allowed. |
["hello"] |
✅ | A string is allowed. |
[false] |
❌ | A boolean is not allowed. |
[] |
❌ | The any element is required (by default, all array elements specify minOccurs=1 ). |
["hello",5.2,"world","foo","bar",6,4,2] |
✅ | Repeating occurrences of myNumber or myString are allowed (by default, all array elements specify maxOccurs=unbounded) . |
The declarative type objects are immediate children of the schema object, and represent type definitions that are referenceable throughout the schema, via any.types
, object.extends
, array.elements.reference
, and object.properties.reference
. The type objects inherit constraint properties from model definitions with the following extensions: (Note that the any and reference Constraint Types are not available as a declarative types).
Property Name | Property Value | |
---|---|---|
( boolean | number | string | object | array | |
name |
Name of declared type Name of type declaration to be used as reference throuthout the JSD. |
{ "jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
...
"rootArray": { "jx:type": "array",
"elements": [...] },
"rootBoolean": { "jx:type": "boolean" },
"rootNumber": { "jx:type": "number" },
"rootString": { "jx:type": "string" },
"rootObject": { "jx:type": "object",
"properties": {...} }
...
}
<schema xmlns="http://www.jsonx.org/schema-0.4.xsd">
...
<array name="rootArray">
...
</array>
<boolean name="rootBoolean"/>
<number name="rootNumber"/>
<string name="rootString"/>
<object name="rootObject">
...
</object>
...
</schema>
The property objects define properties for the declarative objects that belong to an object. The property objects inherit constraint properties from model definitions with the following extensions:
Property Name | Property Value | |
---|---|---|
( boolean | number | string | object | array | any | reference ) |
use nullable |
(required|optional) Specifies whether the property use is required or optional. (true|false) Specifies whether the property is nullable. |
{ "jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
...
"rootObject": { "jx:type": "object",
"properties": {
"propArray": { "jx:type": "array", "nullable": true, "use": "required",
"elements": [...] },
"propBoolean": { "jx:type": "boolean", "nullable": true, "use": "required" },
"propNumber": { "jx:type": "number", "nullable": true, "use": "required" },
"propString": { "jx:type": "string", "nullable": true, "use": "required" },
"propObject": { "jx:type": "object", "nullable": true, "use": "optional",
"properties": {...} },
"propReference": { "jx:type": "reference", "nullable": true, "use": "required", "type": "..." },
".*": { "jx:type": "any", "nullable": true, "use": "optional", "types": "..." }
}
}
...
}
<schema xmlns="http://www.jsonx.org/schema-0.4.xsd">
...
<object name="rootObject">
<property name="propArray" xsi:type="array" nullable="true" use="required">
...
</property>
<property name="propBoolean" xsi:type="boolean" nullable="true" use="required"/>
<property name="propNumber" xsi:type="number" nullable="true" use="required"/>
<property name="propString" xsi:type="string" nullable="true" use="required"/>
<property name="propObject" xsi:type="object" nullable="true" use="optional">
...
</property>
<property name="propReference" xsi:type="reference" nullable="true" use="required" type="..."/>
<property names=".*" xsi:type="any" nullable="true" use="optional" types="..."/>
</object>
...
</schema>
The element objects define properties for the declarative objects that belong to an array. The element objects inherit constraint properties from constraint type definitions with the following extensions:
Property Name | Property Value | |
---|---|---|
( boolean | number | string | object | array | any | reference ) |
nullable minOccurs maxOccurs |
(true|false) Specifies whether the property is nullable. (0|1|2|...) Specifies the minimum inclusive number of occurrence of the member element. (0|1|2|...|unbounded) Specifies the maximum inclusive number of occurrence of the member element. |
{ "jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
...
"rootArray": {
"jx:type": "array",
"elements": [
{ "jx:type": "boolean", "minOccurs": "1", "maxOccurs": "unbounded", "nullable": true},
{ "jx:type": "number", "minOccurs": "1", "maxOccurs": "unbounded", "nullable": true },
{ "jx:type": "string", "minOccurs": "1", "maxOccurs": "unbounded", "nullable": true },
{ "jx:type": "array", "minOccurs": "1", "maxOccurs": "unbounded", "nullable": true,
"elements": [...] },
{ "jx:type": "reference", "minOccurs": "1", "maxOccurs": "unbounded", "nullable": true, "type": "..." },
{ "jx:type": "any", "minOccurs": "1", "maxOccurs": "unbounded", "nullable": true, "types": "..." }
]
}
...
}
<schema xmlns="http://www.jsonx.org/schema-0.4.xsd">
...
<array name="rootArray">
<boolean minOccurs="1" maxOccurs="unbounded" nullable="true"/>
<number minOccurs="1" maxOccurs="unbounded" nullable="true"/>
<string minOccurs="1" maxOccurs="unbounded" nullable="true"/>
<array minOccurs="1" maxOccurs="unbounded" nullable="true">
...
</array>
<reference minOccurs="1" maxOccurs="unbounded" nullable="true" type="...">
<any minOccurs="1" maxOccurs="unbounded" nullable="true" types="..."/>
</array>
...
</schema>
As of JSON Schema 0.4, language specific bindings allow schema document declarations to bind information pertainig to zero or many target languages.
Bindings enable a schema to provide schema processors with information to bridge between JSON and the application layer in a custom way.
The binding information is comprised of five identifiers that belong to a single binding
element:
Property Name | Property Value | |
---|---|---|
( binding ) |
lang type decode encode field |
The language for which the binding is directed. (i.e. "java", "python", "ruby", "custom"). The language specific "type" to which the declaration is to be bound. The method, constructor, or executable that consumes JSON and produces an instance of type (if type is specified), or of the default native type if type is not specified). The method, constructor, or executable that consumes an instance of type (if type is specified), or of the default native type (if type is not specified), and produces JSON. The language specific "field" to which the particular declaration is to be bound. |
Note: lang has been marked in bold to indicate that it is required property.
There are three types of binding
objects:
Type Bindings only allow for the specification of type, decode, and encode properties.
These bindings are allowed on Type Declarations and Array Elements
Field Bindings only allow for the specification of a field property.
These bindings are allowed on reference
Types, and Object Properties of type object
, array
, or any
.
Type/Field Bindings only allow for the specification of all properties: type, decode, encode, and field.
These bindings are allowed on Object Properties of type boolean
, number
, or string
.
-
JSON Schema 0.5 [Development]
-
A JSON Schema schema document XSD schema-0.5.xsd for JSON Schema documents. It incorporates an auxiliary XSD, datatypes-0.9.xsd.
-
A JSON Schema schema document JSDx schema-0.5.jsdx for JSON Schema documents.
-
A JSON Schema schema document JSD schema-0.5.jsd for JSON Schema documents.
-
-
JSON Binding 0.5 [Development]
-
A JSON Binding schema document XSD binding-0.5.xsd for JSON Binding documents.
-
A JSON Binding schema document JSDx binding-0.5.jsdx for JSON Binding documents.
-
A JSON Binding schema document JSD binding-0.5.jsd for JSON Binding documents.
-
-
JSON Include 0.5 [Development]
-
A JSON Include schema document XSD include-0.5.xsd for JSON Include declarations.
-
A JSON Include schema document JSDx include-0.5.jsdx for JSON Include declarations.
-
A JSON Include schema document JSD include-0.5.jsd for JSON Include declarations.
-
-
JSON Schema 0.4 [Current]
-
A JSON Schema schema document XSD schema-0.4.xsd for JSON Schema documents. It incorporates an auxiliary XSD, datatypes-0.9.xsd.
-
A JSON Schema schema document JSDx schema-0.4.jsdx for JSON Schema documents.
-
A JSON Schema schema document JSD schema-0.4.jsd for JSON Schema documents.
-
-
JSON Schema 0.3 [Deprecated]
-
A JSON Schema schema document XSD schema-0.3.xsd for JSON Schema documents. It incorporates an auxiliary XSD, datatypes-0.9.xsd.
-
A JSON Schema schema document JSDx schema-0.3.jsdx for JSON Schema documents.
-
A JSON Schema schema document JSD schema-0.3.jsd for JSON Schema documents.
-
-
JSON Schema 0.2 [Deprecated]
-
A JSON Schema schema document XSD schema-0.2.xsd for JSON Schema documents. It incorporates an auxiliary XSD, datatypes-0.8.xsd.
-
A JSON Schema schema document JSDx schema-0.2.jsdx for JSON Schema documents.
-
A JSON Schema schema document JSD schema-0.2.jsd for JSON Schema documents.
-
-
JSON Schema 0.1 [Deprecated]
-
A JSON Schema schema document XSD schema-0.1.xsd for JSON Schema documents. It incorporates an auxiliary XSD, datatypes-0.8.xsd.
-
A JSON Schema schema document JSDx
schema-0.1.jsdxfor JSON Schema documents. -
A JSON Schema schema document JSD
schema-0.1.jsdfor JSON Schema documents.
-
This section provides sample schemas in both jsdx
and jsd
representations.
<schema
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd"
doc="Schema expressing complex nested structures">
<array name="array">
<boolean nullable="true"/>
<number range="[-1,1)" nullable="true"/>
<string pattern="pattern" nullable="true"/>
<array nullable="true">
<boolean nullable="true"/>
<number range="[-1,1)" nullable="true"/>
<string pattern="pattern" nullable="true"/>
<any types="boolean number string array object"/>
</array>
<reference type="object"/>
<any types="boolean number string array object" nullable="true"/>
</array>
<boolean name="boolean"/>
<number name="number" range="[-1,1)"/>
<string name="string" pattern="pattern"/>
<object name="object">
<property name="array" xsi:type="array" nullable="true" use="required">
<boolean nullable="true"/>
<number range="[-1,1)" nullable="true"/>
<string pattern="pattern" nullable="true"/>
<array nullable="true">
<boolean nullable="true"/>
<number range="[-1,1)" nullable="true"/>
<string pattern="pattern" nullable="true"/>
<any types="boolean number string array object"/>
</array>
<reference type="object"/>
<any types="boolean number string array object" nullable="true"/>
</property>
<property name="boolean" xsi:type="boolean" nullable="true" use="required"/>
<property name="number" xsi:type="number" range="[-1,1)" nullable="true" use="required"/>
<property name="string" xsi:type="string" pattern="pattern" nullable="true" use="required"/>
<property name="booleanRef" xsi:type="reference" type="boolean" nullable="true" use="required"/>
<property name="subObject" xsi:type="object" extends="object" nullable="true" use="optional">
<property name="subBoolean" xsi:type="boolean" nullable="true" use="required"/>
<property name="subNumber" xsi:type="number" range="[-1,1)" nullable="true" use="required"/>
<property name="subString" xsi:type="string" pattern="pattern" nullable="true" use="required"/>
<property name="subBooleanRef" xsi:type="reference" type="boolean" nullable="true" use="required"/>
<property name="subArray" xsi:type="array" nullable="true" use="required">
<boolean nullable="true"/>
<number range="[-1,1)" nullable="true"/>
<string pattern="pattern" nullable="true"/>
<array nullable="true">
<boolean nullable="true"/>
<number range="[-1,1)" nullable="true"/>
<string pattern="pattern" nullable="true"/>
<any types="boolean number string array object"/>
</array>
<reference type="object"/>
<any types="boolean number string array object" nullable="true"/>
</property>
</property>
<property names=".*" xsi:type="any" types="boolean number string array object" nullable="true" use="optional"/>
</object>
</schema>
{
"jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
"jx:schemaLocation": "http://www.jsonx.org/schema-0.4.jsd http://www.jsonx.org/schema.jsd",
"doc": "Schema expressing complex nested structures",
"array": {
"jx:type": "array",
"elements": [{
"jx:type": "boolean"
}, {
"jx:type": "number",
"range": "[-1,1)"
}, {
"jx:type": "string",
"pattern": "pattern"
}, {
"jx:type": "array",
"elements": [{
"jx:type": "boolean"
}, {
"jx:type": "number",
"range": "[-1,1)"
}, {
"jx:type": "string",
"pattern": "pattern"
}, {
"jx:type": "any",
"types": "boolean number string array object"
}]
}, {
"jx:type": "reference",
"type": "object"
}, {
"jx:type": "any",
"types": "boolean number string array object"
}]
},
"boolean": {
"jx:type": "boolean"
},
"number": {
"jx:type": "number",
"range": "[-1,1)"
},
"string": {
"jx:type": "string",
"pattern": "pattern"
},
"object": {
"jx:type": "object",
"properties": {
"array": {
"jx:type": "array",
"elements": [{
"jx:type": "boolean"
}, {
"jx:type": "number",
"range": "[-1,1)"
}, {
"jx:type": "string",
"pattern": "pattern"
}, {
"jx:type": "array",
"elements": [{
"jx:type": "boolean"
}, {
"jx:type": "number",
"range": "[-1,1)"
}, {
"jx:type": "string",
"pattern": "pattern"
}, {
"jx:type": "any",
"types": "boolean number string array object"
}]
}, {
"jx:type": "reference",
"type": "object"
}, {
"jx:type": "any",
"types": "boolean number string array object"
}]
},
"boolean": {
"jx:type": "boolean"
},
"number": {
"jx:type": "number",
"range": "[-1,1)"
},
"string": {
"jx:type": "string",
"pattern": "pattern"
},
"booleanRef": {
"jx:type": "reference",
"type": "boolean"
},
"subObject": {
"jx:type": "object",
"extends": "object",
"use": "optional",
"properties": {
"subBoolean": {
"jx:type": "boolean"
},
"subNumber": {
"jx:type": "number",
"range": "[-1,1)"
},
"subString": {
"jx:type": "string",
"pattern": "pattern"
},
"subBooleanRef": {
"jx:type": "reference",
"type": "boolean"
},
"subArray": {
"jx:type": "array",
"elements": [{
"jx:type": "boolean"
}, {
"jx:type": "number",
"range": "[-1,1)"
}, {
"jx:type": "string",
"pattern": "pattern"
}, {
"jx:type": "array",
"elements": [{
"jx:type": "boolean"
}, {
"jx:type": "number",
"range": "[-1,1)"
}, {
"jx:type": "string",
"pattern": "pattern"
}, {
"jx:type": "any",
"types": "boolean number string array object"
}]
}, {
"jx:type": "reference",
"type": "object"
}, {
"jx:type": "any",
"types": "boolean number string array object"
}]
}
}
},
".*": {
"jx:type": "any",
"types": "boolean number string array object",
"use": "optional"
}
}
}
}
<schema
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd"
targetNamespace="http://www.jsonx.org/generator/test/datatype.jsdx"
doc="Schema intended to express full variability of type declarations">
<array name="arrayArr" doc="Array of arrays">
<reference type="arrayBool" maxOccurs="1" doc="Reference to array of booleans"/>
<reference type="arrayNum" maxOccurs="1" doc="Reference to array of numbers"/>
<reference type="arrayObj" maxOccurs="1" doc="Reference to array of objects"/>
<reference type="arrayObj" maxOccurs="1" doc="Another reference to array of objects"/>
<reference type="arrayStr" maxOccurs="1" doc="Reference to array of strings"/>
<reference type="arrayStr" maxOccurs="1" doc="Another reference to array of strings"/>
<any types="defaultDecimal StringDecimal defaultBoolean StringBoolean" minOccurs="0" maxOccurs="1" nullable="false" doc="Any of defaultDecimal, StringDecimal, defaultBoolean, or StringBoolean type"/>
</array>
<array name="arrayBool" doc="Array of booleans">
<any maxOccurs="1" nullable="false" doc="Any type"/>
<reference type="primitiveBoolean" minOccurs="1" maxOccurs="1" nullable="false" doc="Not-nullable reference to primitiveBoolean"/>
<reference type="defaultBoolean" minOccurs="1" maxOccurs="1" doc="Reference to defaultBoolean"/>
</array>
<array name="arrayNum" doc="Array of numbers">
<any minOccurs="1" maxOccurs="1" nullable="false" doc="Any type"/>
<reference type="defaultDecimal" minOccurs="1" maxOccurs="1" doc="Reference to defaultDecimal"/>
<reference type="byte" minOccurs="1" maxOccurs="1" nullable="false" doc="Reference to byte"/>
<reference type="StringDecimal" minOccurs="1" maxOccurs="1" doc="Reference to StringDecimal"/>
<reference type="numRange" minOccurs="1" maxOccurs="1" nullable="false" doc="Reference to numRange"/>
<reference type="cachedInteger" minOccurs="1" maxOccurs="1" doc="Reference to num"/>
<reference type="plainDecimal" minOccurs="1" maxOccurs="1" nullable="false" doc="Reference to plainDecimal"/>
<reference type="cachedPlainDecimal" minOccurs="1" maxOccurs="1" doc="Reference to plainDecimalRange"/>
<reference type="byte" minOccurs="1" maxOccurs="1" nullable="false" doc="Reference to byte"/>
<reference type="numRange" minOccurs="1" maxOccurs="1" nullable="false" doc="Reference to numRange"/>
<reference type="cachedInteger" minOccurs="1" maxOccurs="1" doc="Reference to cachedInteger"/>
<reference type="defaultDecimalRange2" minOccurs="0" maxOccurs="1" doc="Reference to plainDecimalRange"/>
</array>
<array name="arrayObj" doc="Array of object references">
<reference type="objArr" maxOccurs="1" doc="Reference to objArr"/>
<reference type="objBool" maxOccurs="1" doc="Reference to objBool"/>
<reference type="objNum" maxOccurs="1" doc="Reference to objNum"/>
<reference type="objObj" maxOccurs="1" doc="Reference to objObj"/>
<reference type="objStr" maxOccurs="1" doc="Reference to objStr"/>
</array>
<array name="arrayStr" doc="Array of string references">
<any types="byte primitiveBoolean" maxOccurs="1" nullable="false" doc="Any type with primitive byte and boolean"/>
<reference type="defaultString" maxOccurs="1" doc="Reference to defaultString"/>
<reference type="charArray" maxOccurs="1" nullable="false" doc="Not-nullable reference to charArray"/>
<reference type="uuid" maxOccurs="1" doc="Reference to uuid"/>
<reference type="uuid" maxOccurs="1" nullable="false" doc="Not-nullable to uuid"/>
<reference type="url" maxOccurs="1" doc="Reference to url"/>
<reference type="url" maxOccurs="1" nullable="false" doc="Not-nullable to url"/>
<reference type="StringBigDecimal" maxOccurs="1" doc="Reference to StringBigDecimal"/>
<reference type="StringBigDecimal" maxOccurs="1" nullable="false" doc="Not-nullable to StringBigDecimal"/>
<reference type="nonEmptyString" maxOccurs="1" doc="Reference to nonEmptyString"/>
<reference type="nonEmptyString" minOccurs="2" maxOccurs="3" nullable="false" doc="Not-nullable to nonEmptyString"/>
</array>
<boolean name="defaultBoolean" doc="Default boolean"/>
<boolean name="primitiveBoolean" doc="Primitive boolean">
<binding lang="java" type="boolean" encode="java.lang.String.valueOf"/>
</boolean>
<boolean name="StringBoolean">
<binding lang="java" type="java.lang.String" decode="java.lang.String.valueOf"/>
</boolean>
<number name="defaultDecimal" doc="Default decimal type"/>
<number name="defaultInteger" scale="0" doc="Default integer type"/>
<number name="byte" scale="0" range="[-64,63]" doc="Primitive byte type">
<binding lang="java" type="byte"/>
</number>
<number name="Short" scale="0" range="[-16384,16383]" doc="Short number type">
<binding lang="java" type="java.lang.Short"/>
</number>
<number name="StringDecimal">
<binding lang="java" type="java.lang.CharSequence"/>
</number>
<number name="numRange" range="[1e10,]" doc="Template for number type with range"/>
<number name="cachedInteger" scale="0" range="[1,]" doc="Template for integer number type with range">
<binding lang="java" type="java.math.BigInteger" decode="org.libj.math.BigIntegers.intern"/>
</number>
<number name="plainDecimal" scale="2" doc="Template cached BigDecimal">
<binding lang="java" type="java.math.BigDecimal" encode="this.toPlainString"/>
</number>
<number name="cachedPlainDecimal" scale="3" range="[-2.222e-12,]" doc="First template for real number type with range">
<binding lang="java" type="java.math.BigDecimal" decode="org.libj.math.BigDecimals.intern" encode="this.toPlainString"/>
</number>
<number name="defaultDecimalRange2" scale="3" range="[-2.222e-12,]" doc="Second template for real number type with range"/>
<string name="defaultString" doc="Default string type"/>
<string name="charArray" doc="char[] type">
<binding lang="java" type="char[]" decode="org.libj.lang.Characters.valueOf" encode="java.lang.String.<init>"/>
</string>
<string name="uuid" pattern="[0-9]{8}-[a-f]{4}-[0-9]{4}-[a-f]{4}-[0-9]{12}" doc="UUID pattern with UUID type">
<binding lang="java" type="java.util.UUID" decode="org.libj.lang.Strings.toUuidOrNull"/>
</string>
<string name="url" pattern="((https?|ftp)://jsonx.org/[\w\d:#@%/;$()~_?'\+-=\\\.&]+)" doc="URL pattern with URL type">
<binding lang="java" type="java.net.URL" decode="java.net.URL.<init>"/>
</string>
<string name="StringBigDecimal" pattern="\d+(\.\d+)?([eE][+-]?\d{1,5})?" doc="An integer with BigDecimal type represented as a string">
<binding lang="java" type="java.math.BigDecimal" decode="java.math.BigDecimal.<init>"/>
</string>
<string name="nonEmptyString" pattern="(\S)|(\S.*\S)" doc="Non-empty string"/>
<object name="objTest" doc="Object with array references">
<property names="anyNumStr" xsi:type="any" types="defaultDecimal charArray" use="optional" doc="Optional property named anyNumStr of type 'defaultDecimal' or 'charArray'"/>
</object>
<object name="objArr" doc="Object with array references">
<property names=".*" xsi:type="any" nullable="false" doc="Property accepting any name and any type">
<binding lang="java" field="any1"/>
</property>
<property name="arrayBool" xsi:type="reference" type="arrayBool" doc="Property with bool array">
<binding lang="java" field="ab"/>
</property>
<property name="arrayBoolOptional" xsi:type="reference" type="arrayBool" use="optional" doc="Optional property with bool array">
<binding lang="java" field="abO"/>
</property>
<property name="arrayBoolOptionalNotNullable" xsi:type="reference" type="arrayBool" use="optional" nullable="false" doc="Optional, not-nullable property with bool array">
<binding lang="java" field="abONN"/>
</property>
<property name="arrayNum" xsi:type="reference" type="arrayNum" doc="Property with num array">
<binding lang="java" field="an"/>
</property>
<property name="arrayNumOptional" xsi:type="reference" type="arrayNum" use="optional" doc="Optional property with num array">
<binding lang="java" field="anO"/>
</property>
<property name="arrayNumOptionalNotNullable" xsi:type="reference" type="arrayNum" use="optional" nullable="false" doc="Optional, not-nullable property with num array">
<binding lang="java" field="anONN"/>
</property>
<property name="arrayStr" xsi:type="reference" type="arrayStr" doc="Property with str array">
<binding lang="java" field="as"/>
</property>
<property name="arrayStrOptional" xsi:type="reference" type="arrayStr" use="optional" doc="Optional property with str array">
<binding lang="java" field="asO"/>
</property>
<property name="arrayStrOptionalNotNullable" xsi:type="reference" type="arrayStr" use="optional" nullable="false" doc="Optional, not-nullable property with str array">
<binding lang="java" field="asONN"/>
</property>
<property names="anyNumStr" xsi:type="any" types="defaultDecimal charArray" use="optional" doc="Optional property named anyNumStr of type 'defaultDecimal' or 'charArray'">
<binding lang="java" field="any2"/>
</property>
</object>
<object name="objBool" doc="Object with boolean properties">
<property name="bo+l" xsi:type="reference" type="primitiveBoolean" nullable="false" doc="Not-nullable property with name matching a regex of type primitiveBoolean">
<binding lang="java" field="bool1"/>
</property>
<property names=".*" xsi:type="any" types="primitiveBoolean defaultDecimal" nullable="false" doc="Not-nullable property of any name and of type 'primitiveBoolean' or 'defaultDecimal'">
<binding lang="java" field="any"/>
</property>
<property name="bo+lOptional" xsi:type="reference" type="StringBoolean" use="optional" doc="Optional property with name matching a regex of type StringBoolean">
<binding lang="java" field="bool2"/>
</property>
<property name="boolOptionalNotNullable" xsi:type="reference" type="defaultBoolean" use="optional" nullable="false" doc="Not-nullable, optional property with name matching a regex of type defaultBoolean">
<binding lang="java" field="bool3"/>
</property>
</object>
<object name="objNum" doc="Object with number properties">
<property name="num.+" xsi:type="reference" type="defaultDecimal" doc="Property with name matching a regex of type defaultDecimal">
<binding lang="java" field="regexNum"/>
</property>
<property name="numRequired" xsi:type="reference" type="defaultDecimal" doc="Required property for defaultDecimal type"/>
<property name="numOptional" xsi:type="reference" type="defaultDecimal" use="optional" doc="Optional property for defaultDecimal type"/>
<property name="numRequiredNotNullable" xsi:type="reference" type="defaultDecimal" nullable="false" doc="Required and not-nullable property for defaultDecimal type"/>
<property name="numOptionalNotNullable" xsi:type="reference" type="defaultDecimal" use="optional" nullable="false" doc="Optional and not-nullable property for defaultDecimal type"/>
<property names="any" xsi:type="any" types="defaultDecimal charArray" nullable="false" doc="Property named 'any' of type 'defaultDecimal or 'charArray'"/>
<property name="numIntRequired" xsi:type="reference" type="Short" doc="Required property referencing type byte"/>
<property name="numIntOptional" xsi:type="reference" type="StringDecimal" use="optional" doc="Optional property referencing type StringDecimal"/>
<property name="numIntRequiredNotNullable" xsi:type="reference" type="byte" nullable="false" doc="Required, not-nullable property referencing type byte"/>
<property name="numIntOptionalNotNullable" xsi:type="reference" type="defaultInteger" use="optional" nullable="false" doc="Optional, not-nullable property referencing type defaultInteger"/>
<property name="numRangeRequired" xsi:type="reference" type="numRange" doc="Required property referencing type numRange"/>
<property name="numRangeOptional" xsi:type="reference" type="numRange" use="optional" doc="Optional property referencing type numRange"/>
<property name="numRangeRequiredNotNullable" xsi:type="reference" type="numRange" nullable="false" doc="Required, not-nullable property referencing type numRange"/>
<property name="numRangeOptionalNotNullable" xsi:type="reference" type="numRange" use="optional" nullable="false" doc="Optional, not-nullable property referencing type numRange"/>
<property name="cachedIntegerRequired" xsi:type="reference" type="cachedInteger" doc="Required property referencing type cachedInteger"/>
<property name="cachedIntegerOptional" xsi:type="reference" type="cachedInteger" use="optional" doc="Optional property referencing type cachedInteger"/>
<property name="cachedIntegerRequiredNotNullable" xsi:type="reference" type="cachedInteger" nullable="false" doc="Required, not-nullable property referencing type cachedInteger"/>
<property name="cachedIntegerOptionalNotNullable" xsi:type="reference" type="cachedInteger" use="optional" nullable="false" doc="Optional, not-nullable property referencing type cachedInteger"/>
<property name="plainDecimalRequired" xsi:type="reference" type="plainDecimal" doc="Required property referencing type plainDecimal"/>
<property name="plainDecimalOptional" xsi:type="reference" type="plainDecimal" use="optional" doc="Optional property referencing type plainDecimal"/>
<property name="plainDecimalRequiredNotNullable" xsi:type="reference" type="plainDecimal" nullable="false" doc="Required, not-nullable property referencing type plainDecimal"/>
<property name="plainDecimalOptionalNotNullable" xsi:type="reference" type="plainDecimal" use="optional" nullable="false" doc="Optional, not-nullable property referencing type plainDecimal"/>
<property name="plainDecimalRangeRequired" xsi:type="reference" type="cachedPlainDecimal" doc="Required property referencing type cachedPlainDecimal"/>
<property name="plainDecimalRangeOptional" xsi:type="reference" type="defaultDecimalRange2" use="optional" doc="Optional property referencing type defaultDecimalRange2"/>
<property name="plainDecimalRangeRequiredNotNullable" xsi:type="reference" type="defaultDecimalRange2" nullable="false" doc="Required, not-nullable property referencing type defaultDecimalRange2"/>
<property name="plainDecimalRangeOptionalNotNullable" xsi:type="reference" type="cachedPlainDecimal" use="optional" nullable="false" doc="Optional, not-nullable property referencing type cachedPlainDecimal"/>
</object>
<object name="objObj" doc="Object of objects">
<property name="objOptional" xsi:type="reference" type="objBool" use="optional" doc="Optional reference to objBool">
<binding lang="java" field="obj1"/>
</property>
<property name="objOptionalNotNullable" xsi:type="reference" type="objNum" use="optional" nullable="false" doc="Optional, not-nullable reference to objNum">
<binding lang="java" field="obj2"/>
</property>
<property name="objExtends1" xsi:type="object" extends="objObj" use="optional" doc="Nested definition of optional object extending objObj">
<property name="objExtends2" xsi:type="object" extends="objObj" use="optional" doc="Further nested definition of optional object extending objObj">
<property name="objExtends3" xsi:type="object" extends="objObj" use="optional" doc="Further more nested definition of optional object extending objObj">
<property name="objExtends4" xsi:type="object" extends="objObj" use="optional" doc="And yet further more nested definition of optional object extending objObj">
<property name="defaultDecimal" xsi:type="reference" type="defaultDecimal" use="optional" doc="Optional property named 'defaultDecimal' of type 'defaultDecimal'">
<binding lang="java" field="objX"/>
</property>
<binding lang="java" field="objX"/>
</property>
</property>
<binding lang="java" field="objX"/>
</property>
<binding lang="java" field="obj3"/>
</property>
<property name="objExtendsOptional" xsi:type="object" extends="objBool" use="optional" doc="Optional property of nested object definition extending objBool">
<property name="defaultString" xsi:type="reference" type="defaultString" doc="Optional property named 'defaultString' of type 'defaultString'"/>
<property name="charArray" xsi:type="reference" type="charArray" doc="Optional property named 'charArray' of type 'charArray'"/>
<binding lang="java" field="obj4"/>
</property>
<property name="objExtendsOptionalNotNullable" xsi:type="object" extends="objBool" use="optional" nullable="false">
<property name="arrayBool" xsi:type="reference" type="arrayBool" doc="Optional property named 'arrayBool' of type 'arrayBool'"/>
<binding lang="java" field="obj5"/>
</property>
</object>
<object name="objStr" doc="Object definition with properties of string types">
<property name="defaultString" xsi:type="reference" type="defaultString" doc="Property referencing 'defaultString' type"/>
<property name="defaultStringOptional" xsi:type="reference" type="defaultString" use="optional" doc="Optional property referencing 'defaultString' type"/>
<property name="defaultStringOptionalNotNullable" xsi:type="reference" type="defaultString" use="optional" nullable="false" doc="Optional, not-nullable property referencing 'defaultString' type"/>
<property name="charArray" xsi:type="reference" type="charArray" doc="Property referencing 'charArray' type"/>
<property name="charArrayOptional" xsi:type="reference" type="charArray" use="optional" doc="Optional property referencing 'charArray' type"/>
<property name="charArrayOptionalNotNullable" xsi:type="reference" type="charArray" use="optional" nullable="false" doc="Optional, not-nullable property referencing 'charArray' type"/>
<property name="uuid" xsi:type="reference" type="uuid" doc="Property referencing 'uuid' type"/>
<property name="uuidOptional" xsi:type="reference" type="uuid" use="optional" doc="Optional property referencing 'uuid' type"/>
<property name="uuidOptionalNotNullable" xsi:type="reference" type="uuid" use="optional" nullable="false" doc="Optional, not-nullable property referencing 'uuid' type"/>
<property name="url" xsi:type="reference" type="url" doc="Property referencing 'url' type"/>
<property name="urlOptional" xsi:type="reference" type="url" use="optional" doc="Optional property referencing 'url' type"/>
<property name="urlOptionalNotNullable" xsi:type="reference" type="url" use="optional" nullable="false" doc="Optional, not-nullable property referencing 'url' type"/>
<property name="StringBigDecimal" xsi:type="reference" type="StringBigDecimal" doc="Property referencing 'StringBigDecimal' type"/>
<property name="StringBigDecimalOptional" xsi:type="reference" type="StringBigDecimal" use="optional" doc="Optional property referencing 'StringBigDecimal' type"/>
<property name="StringBigDecimalOptionalNotNullable" xsi:type="reference" type="StringBigDecimal" use="optional" nullable="false" doc="Optional, not-nullable property referencing 'StringBigDecimal' type"/>
<property name="nonEmptyString" xsi:type="reference" type="nonEmptyString" doc="Property referencing 'nonEmptyString' type"/>
<property name="nonEmptyStringOptional" xsi:type="reference" type="nonEmptyString" use="optional" doc="Optional property referencing 'nonEmptyString' type"/>
<property name="nonEmptyStringOptionalNotNullable" xsi:type="reference" type="nonEmptyString" use="optional" nullable="false" doc="Optional, not-nullable property referencing 'nonEmptyString' type"/>
</object>
</schema>
{
"jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
"jx:schemaLocation": "http://www.jsonx.org/schema-0.4.jsd http://www.jsonx.org/schema-0.4.jsd",
"jx:targetNamespace": "http://www.jsonx.org/generator/test/datatype.jsdx",
"doc": "Schema intended to express full variability of type declarations",
"arrayArr": {
"jx:type": "array",
"doc": "Array of arrays",
"elements": [{
"jx:type": "reference",
"type": "arrayBool",
"maxOccurs": "1",
"doc": "Reference to array of booleans"
}, {
"jx:type": "reference",
"type": "arrayNum",
"maxOccurs": "1",
"doc": "Reference to array of numbers"
}, {
"jx:type": "reference",
"type": "arrayObj",
"maxOccurs": "1",
"doc": "Reference to array of objects"
}, {
"jx:type": "reference",
"type": "arrayObj",
"maxOccurs": "1",
"doc": "Another reference to array of objects"
}, {
"jx:type": "reference",
"type": "arrayStr",
"maxOccurs": "1",
"doc": "Reference to array of strings"
}, {
"jx:type": "reference",
"type": "arrayStr",
"maxOccurs": "1",
"doc": "Another reference to array of strings"
}, {
"jx:type": "any",
"types": "defaultDecimal StringDecimal defaultBoolean StringBoolean",
"minOccurs": "0",
"maxOccurs": "1",
"nullable": false,
"doc": "Any of defaultDecimal, StringDecimal, defaultBoolean, or StringBoolean type"
}]
},
"arrayBool": {
"jx:type": "array",
"doc": "Array of booleans",
"elements": [{
"jx:type": "any",
"maxOccurs": "1",
"nullable": false,
"doc": "Any type"
}, {
"jx:type": "reference",
"type": "primitiveBoolean",
"maxOccurs": "1",
"nullable": false,
"doc": "Not-nullable reference to primitiveBoolean"
}, {
"jx:type": "reference",
"type": "defaultBoolean",
"maxOccurs": "1",
"doc": "Reference to defaultBoolean"
}]
},
"arrayNum": {
"jx:type": "array",
"doc": "Array of numbers",
"elements": [{
"jx:type": "any",
"maxOccurs": "1",
"nullable": false,
"doc": "Any type"
}, {
"jx:type": "reference",
"type": "defaultDecimal",
"maxOccurs": "1",
"doc": "Reference to defaultDecimal"
}, {
"jx:type": "reference",
"type": "byte",
"maxOccurs": "1",
"nullable": false,
"doc": "Reference to byte"
}, {
"jx:type": "reference",
"type": "StringDecimal",
"maxOccurs": "1",
"doc": "Reference to StringDecimal"
}, {
"jx:type": "reference",
"type": "numRange",
"maxOccurs": "1",
"nullable": false,
"doc": "Reference to numRange"
}, {
"jx:type": "reference",
"type": "cachedInteger",
"maxOccurs": "1",
"doc": "Reference to num"
}, {
"jx:type": "reference",
"type": "plainDecimal",
"maxOccurs": "1",
"nullable": false,
"doc": "Reference to plainDecimal"
}, {
"jx:type": "reference",
"type": "cachedPlainDecimal",
"maxOccurs": "1",
"doc": "Reference to plainDecimalRange"
}, {
"jx:type": "reference",
"type": "byte",
"maxOccurs": "1",
"nullable": false,
"doc": "Reference to byte"
}, {
"jx:type": "reference",
"type": "numRange",
"maxOccurs": "1",
"nullable": false,
"doc": "Reference to numRange"
}, {
"jx:type": "reference",
"type": "cachedInteger",
"maxOccurs": "1",
"doc": "Reference to cachedInteger"
}, {
"jx:type": "reference",
"type": "defaultDecimalRange2",
"minOccurs": "0",
"maxOccurs": "1",
"doc": "Reference to plainDecimalRange"
}]
},
"arrayObj": {
"jx:type": "array",
"doc": "Array of object references",
"elements": [{
"jx:type": "reference",
"type": "objArr",
"maxOccurs": "1",
"doc": "Reference to objArr"
}, {
"jx:type": "reference",
"type": "objBool",
"maxOccurs": "1",
"doc": "Reference to objBool"
}, {
"jx:type": "reference",
"type": "objNum",
"maxOccurs": "1",
"doc": "Reference to objNum"
}, {
"jx:type": "reference",
"type": "objObj",
"maxOccurs": "1",
"doc": "Reference to objObj"
}, {
"jx:type": "reference",
"type": "objStr",
"maxOccurs": "1",
"doc": "Reference to objStr"
}]
},
"arrayStr": {
"jx:type": "array",
"doc": "Array of string references",
"elements": [{
"jx:type": "any",
"types": "byte primitiveBoolean",
"maxOccurs": "1",
"nullable": false,
"doc": "Any type with primitive byte and boolean"
}, {
"jx:type": "reference",
"type": "defaultString",
"maxOccurs": "1",
"doc": "Reference to defaultString"
}, {
"jx:type": "reference",
"type": "charArray",
"maxOccurs": "1",
"nullable": false,
"doc": "Not-nullable reference to charArray"
}, {
"jx:type": "reference",
"type": "uuid",
"maxOccurs": "1",
"doc": "Reference to uuid"
}, {
"jx:type": "reference",
"type": "uuid",
"maxOccurs": "1",
"nullable": false,
"doc": "Not-nullable to uuid"
}, {
"jx:type": "reference",
"type": "url",
"maxOccurs": "1",
"doc": "Reference to url"
}, {
"jx:type": "reference",
"type": "url",
"maxOccurs": "1",
"nullable": false,
"doc": "Not-nullable to url"
}, {
"jx:type": "reference",
"type": "StringBigDecimal",
"maxOccurs": "1",
"doc": "Reference to StringBigDecimal"
}, {
"jx:type": "reference",
"type": "StringBigDecimal",
"maxOccurs": "1",
"nullable": false,
"doc": "Not-nullable to StringBigDecimal"
}, {
"jx:type": "reference",
"type": "nonEmptyString",
"maxOccurs": "1",
"doc": "Reference to nonEmptyString"
}, {
"jx:type": "reference",
"type": "nonEmptyString",
"minOccurs": "2",
"maxOccurs": "3",
"nullable": false,
"doc": "Not-nullable to nonEmptyString"
}]
},
"defaultBoolean": {
"jx:type": "boolean",
"doc": "Default boolean"
},
"primitiveBoolean": {
"jx:type": "boolean",
"doc": "Primitive boolean",
"bindings": [{
"lang": "java",
"type": "boolean",
"encode": "java.lang.String.valueOf"
}]
},
"StringBoolean": {
"jx:type": "boolean",
"bindings": [{
"lang": "java",
"type": "java.lang.String",
"decode": "java.lang.String.valueOf"
}]
},
"defaultDecimal": {
"jx:type": "number",
"doc": "Default decimal type"
},
"defaultInteger": {
"jx:type": "number",
"scale": 0,
"doc": "Default integer type"
},
"byte": {
"jx:type": "number",
"scale": 0,
"range": "[-64,63]",
"doc": "Primitive byte type",
"bindings": [{
"lang": "java",
"type": "byte"
}]
},
"Short": {
"jx:type": "number",
"scale": 0,
"range": "[-16384,16383]",
"doc": "Short number type",
"bindings": [{
"lang": "java",
"type": "java.lang.Short"
}]
},
"StringDecimal": {
"jx:type": "number",
"bindings": [{
"lang": "java",
"type": "java.lang.CharSequence"
}]
},
"numRange": {
"jx:type": "number",
"range": "[1E+10,]",
"doc": "Template for number type with range"
},
"cachedInteger": {
"jx:type": "number",
"scale": 0,
"range": "[1,]",
"doc": "Template for integer number type with range",
"bindings": [{
"lang": "java",
"type": "java.math.BigInteger",
"decode": "org.libj.math.BigIntegers.intern"
}]
},
"plainDecimal": {
"jx:type": "number",
"scale": 2,
"doc": "Template cached BigDecimal",
"bindings": [{
"lang": "java",
"type": "java.math.BigDecimal",
"encode": "this.toPlainString"
}]
},
"cachedPlainDecimal": {
"jx:type": "number",
"scale": 3,
"range": "[-2.222E-12,]",
"doc": "First template for real number type with range",
"bindings": [{
"lang": "java",
"type": "java.math.BigInteger",
"decode": "org.libj.math.BigDecimals.intern",
"encode": "this.toPlainString"
}]
},
"defaultDecimalRange2": {
"jx:type": "number",
"scale": 3,
"range": "[-2.222E-12,]",
"doc": "Second template for real number type with range"
},
"defaultString": {
"jx:type": "string",
"doc": "Default string type"
},
"charArray": {
"jx:type": "string",
"doc": "char[] type",
"bindings": [{
"lang": "java",
"type": "char[]",
"decode": "org.libj.lang.Characters.valueOf",
"encode": "java.lang.String.<init>"
}]
},
"uuid": {
"jx:type": "string",
"pattern": "[0-9]{8}-[a-f]{4}-[0-9]{4}-[a-f]{4}-[0-9]{12}",
"doc": "UUID pattern with UUID type",
"bindings": [{
"lang": "java",
"type": "java.util.UUID",
"decode": "org.libj.lang.Strings.toUuidOrNull"
}]
},
"url": {
"jx:type": "string",
"pattern": "((https?|ftp)://jsonx.org/[\\w\\d:#@%/;$()~_?'\\+-=\\\\\\.&]+)",
"doc": "URL pattern with URL type",
"bindings": [{
"lang": "java",
"type": "java.net.URL",
"decode": "java.net.URL.<init>"
}]
},
"StringBigDecimal": {
"jx:type": "string",
"pattern": "\\d+(\\.\\d+)?([eE][+-]?\\d{1,5})?",
"doc": "An integer with BigDecimal type represented as a string",
"bindings": [{
"lang": "java",
"type": "java.math.BigDecimal",
"decode": "java.math.BigDecimal.<init>"
}]
},
"nonEmptyString": {
"jx:type": "string",
"pattern": "(\\S)|(\\S.*\\S)",
"doc": "Non-empty string"
},
"objTest": {
"jx:type": "object",
"doc": "Object with array references",
"properties": {
"anyNumStr": {
"jx:type": "any",
"types": "defaultDecimal charArray",
"use": "optional",
"doc": "Optional property named anyNumStr of type 'defaultDecimal' or 'charArray'"
}
}
},
"objArr": {
"jx:type": "object",
"doc": "Object with array references",
"properties": {
".*": {
"jx:type": "any",
"nullable": false,
"doc": "Property accepting any name and any type",
"bindings": [{
"lang": "java",
"field": "any1"
}]
},
"arrayBool": {
"jx:type": "reference",
"type": "arrayBool",
"doc": "Property with bool array",
"bindings": [{
"lang": "java",
"field": "ab"
}]
},
"arrayBoolOptional": {
"jx:type": "reference",
"type": "arrayBool",
"use": "optional",
"doc": "Optional property with bool array",
"bindings": [{
"lang": "java",
"field": "abO"
}]
},
"arrayBoolOptionalNotNullable": {
"jx:type": "reference",
"type": "arrayBool",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable property with bool array",
"bindings": [{
"lang": "java",
"field": "abONN"
}]
},
"arrayNum": {
"jx:type": "reference",
"type": "arrayNum",
"doc": "Property with num array",
"bindings": [{
"lang": "java",
"field": "an"
}]
},
"arrayNumOptional": {
"jx:type": "reference",
"type": "arrayNum",
"use": "optional",
"doc": "Optional property with num array",
"bindings": [{
"lang": "java",
"field": "anO"
}]
},
"arrayNumOptionalNotNullable": {
"jx:type": "reference",
"type": "arrayNum",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable property with num array",
"bindings": [{
"lang": "java",
"field": "anONN"
}]
},
"arrayStr": {
"jx:type": "reference",
"type": "arrayStr",
"doc": "Property with str array",
"bindings": [{
"lang": "java",
"field": "as"
}]
},
"arrayStrOptional": {
"jx:type": "reference",
"type": "arrayStr",
"use": "optional",
"doc": "Optional property with str array",
"bindings": [{
"lang": "java",
"field": "asO"
}]
},
"arrayStrOptionalNotNullable": {
"jx:type": "reference",
"type": "arrayStr",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable property with str array",
"bindings": [{
"lang": "java",
"field": "asONN"
}]
},
"anyNumStr": {
"jx:type": "any",
"types": "defaultDecimal charArray",
"use": "optional",
"doc": "Optional property named anyNumStr of type 'defaultDecimal' or 'charArray'",
"bindings": [{
"lang": "java",
"field": "any2"
}]
}
}
},
"objBool": {
"jx:type": "object",
"doc": "Object with boolean properties",
"properties": {
"bo+l": {
"jx:type": "reference",
"type": "primitiveBoolean",
"nullable": false,
"doc": "Not-nullable property with name matching a regex of type primitiveBoolean",
"bindings": [{
"lang": "java",
"field": "bool1"
}]
},
".*": {
"jx:type": "any",
"types": "primitiveBoolean defaultDecimal",
"nullable": false,
"doc": "Not-nullable property of any name and of type 'primitiveBoolean' or 'defaultDecimal'",
"bindings": [{
"lang": "java",
"field": "any"
}]
},
"bo+lOptional": {
"jx:type": "reference",
"type": "StringBoolean",
"use": "optional",
"doc": "Optional property with name matching a regex of type StringBoolean",
"bindings": [{
"lang": "java",
"field": "bool2"
}]
},
"boolOptionalNotNullable": {
"jx:type": "reference",
"type": "defaultBoolean",
"use": "optional",
"nullable": false,
"doc": "Not-nullable, optional property with name matching a regex of type defaultBoolean",
"bindings": [{
"lang": "java",
"field": "bool3"
}]
}
}
},
"objNum": {
"jx:type": "object",
"doc": "Object with number properties",
"properties": {
"num.+": {
"jx:type": "reference",
"type": "defaultDecimal",
"doc": "Property with name matching a regex of type defaultDecimal",
"bindings": [{
"lang": "java",
"field": "regexNum"
}]
},
"numRequired": {
"jx:type": "reference",
"type": "defaultDecimal",
"doc": "Required property for defaultDecimal type"
},
"numOptional": {
"jx:type": "reference",
"type": "defaultDecimal",
"use": "optional",
"doc": "Optional property for defaultDecimal type"
},
"numRequiredNotNullable": {
"jx:type": "reference",
"type": "defaultDecimal",
"nullable": false,
"doc": "Required and not-nullable property for defaultDecimal type"
},
"numOptionalNotNullable": {
"jx:type": "reference",
"type": "defaultDecimal",
"use": "optional",
"nullable": false,
"doc": "Optional and not-nullable property for defaultDecimal type"
},
"any": {
"jx:type": "any",
"types": "defaultDecimal charArray",
"nullable": false,
"doc": "Property named 'any' of type 'defaultDecimal or 'charArray'"
},
"numIntRequired": {
"jx:type": "reference",
"type": "Short",
"doc": "Required property referencing type byte"
},
"numIntOptional": {
"jx:type": "reference",
"type": "StringDecimal",
"use": "optional",
"doc": "Optional property referencing type StringDecimal"
},
"numIntRequiredNotNullable": {
"jx:type": "reference",
"type": "byte",
"nullable": false,
"doc": "Required, not-nullable property referencing type byte"
},
"numIntOptionalNotNullable": {
"jx:type": "reference",
"type": "defaultInteger",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable property referencing type defaultInteger"
},
"numRangeRequired": {
"jx:type": "reference",
"type": "numRange",
"doc": "Required property referencing type numRange"
},
"numRangeOptional": {
"jx:type": "reference",
"type": "numRange",
"use": "optional",
"doc": "Optional property referencing type numRange"
},
"numRangeRequiredNotNullable": {
"jx:type": "reference",
"type": "numRange",
"nullable": false,
"doc": "Required, not-nullable property referencing type numRange"
},
"numRangeOptionalNotNullable": {
"jx:type": "reference",
"type": "numRange",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable property referencing type numRange"
},
"cachedIntegerRequired": {
"jx:type": "reference",
"type": "cachedInteger",
"doc": "Required property referencing type cachedInteger"
},
"cachedIntegerOptional": {
"jx:type": "reference",
"type": "cachedInteger",
"use": "optional",
"doc": "Optional property referencing type cachedInteger"
},
"cachedIntegerRequiredNotNullable": {
"jx:type": "reference",
"type": "cachedInteger",
"nullable": false,
"doc": "Required, not-nullable property referencing type cachedInteger"
},
"cachedIntegerOptionalNotNullable": {
"jx:type": "reference",
"type": "cachedInteger",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable property referencing type cachedInteger"
},
"plainDecimalRequired": {
"jx:type": "reference",
"type": "plainDecimal",
"doc": "Required property referencing type plainDecimal"
},
"plainDecimalOptional": {
"jx:type": "reference",
"type": "plainDecimal",
"use": "optional",
"doc": "Optional property referencing type plainDecimal"
},
"plainDecimalRequiredNotNullable": {
"jx:type": "reference",
"type": "plainDecimal",
"nullable": false,
"doc": "Required, not-nullable property referencing type plainDecimal"
},
"plainDecimalOptionalNotNullable": {
"jx:type": "reference",
"type": "plainDecimal",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable property referencing type plainDecimal"
},
"plainDecimalRangeRequired": {
"jx:type": "reference",
"type": "cachedPlainDecimal",
"doc": "Required property referencing type cachedPlainDecimal"
},
"plainDecimalRangeOptional": {
"jx:type": "reference",
"type": "defaultDecimalRange2",
"use": "optional",
"doc": "Optional property referencing type defaultDecimalRange2"
},
"plainDecimalRangeRequiredNotNullable": {
"jx:type": "reference",
"type": "defaultDecimalRange2",
"nullable": false,
"doc": "Required, not-nullable property referencing type defaultDecimalRange2"
},
"plainDecimalRangeOptionalNotNullable": {
"jx:type": "reference",
"type": "cachedPlainDecimal",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable property referencing type cachedPlainDecimal"
}
}
},
"objObj": {
"jx:type": "object",
"doc": "Object of objects",
"properties": {
"objOptional": {
"jx:type": "reference",
"type": "objBool",
"use": "optional",
"doc": "Optional reference to objBool",
"bindings": [{
"lang": "java",
"field": "obj1"
}]
},
"objOptionalNotNullable": {
"jx:type": "reference",
"type": "objNum",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable reference to objNum",
"bindings": [{
"lang": "java",
"field": "obj2"
}]
},
"objExtends1": {
"jx:type": "object",
"extends": "objObj",
"use": "optional",
"doc": "Nested definition of optional object extending objObj",
"bindings": [{
"lang": "java",
"field": "obj3"
}],
"properties": {
"objExtends2": {
"jx:type": "object",
"extends": "objObj",
"use": "optional",
"doc": "Further nested definition of optional object extending objObj",
"bindings": [{
"lang": "java",
"field": "objX"
}],
"properties": {
"objExtends3": {
"jx:type": "object",
"extends": "objObj",
"use": "optional",
"doc": "Further more nested definition of optional object extending objObj",
"properties": {
"objExtends4": {
"jx:type": "object",
"extends": "objObj",
"use": "optional",
"doc": "And yet further more nested definition of optional object extending objObj",
"bindings": [{
"lang": "java",
"field": "objX"
}],
"properties": {
"defaultDecimal": {
"jx:type": "reference",
"type": "defaultDecimal",
"use": "optional",
"doc": "Optional property named 'defaultDecimal' of type 'defaultDecimal'",
"bindings": [{
"lang": "java",
"field": "objX"
}]
}
}
}
}
}
}
}
}
},
"objExtendsOptional": {
"jx:type": "object",
"extends": "objBool",
"use": "optional",
"doc": "Optional property of nested object definition extending objBool",
"bindings": [{
"lang": "java",
"field": "obj4"
}],
"properties": {
"defaultString": {
"jx:type": "reference",
"type": "defaultString",
"doc": "Optional property named 'defaultString' of type 'defaultString'"
},
"charArray": {
"jx:type": "reference",
"type": "charArray",
"doc": "Optional property named 'charArray' of type 'charArray'"
}
}
},
"objExtendsOptionalNotNullable": {
"jx:type": "object",
"extends": "objBool",
"use": "optional",
"nullable": false,
"bindings": [{
"lang": "java",
"field": "obj5"
}],
"properties": {
"arrayBool": {
"jx:type": "reference",
"type": "arrayBool",
"doc": "Optional property named 'arrayBool' of type 'arrayBool'"
}
}
}
}
},
"objStr": {
"jx:type": "object",
"doc": "Object definition with properties of string types",
"properties": {
"defaultString": {
"jx:type": "reference",
"type": "defaultString",
"doc": "Property referencing 'defaultString' type"
},
"defaultStringOptional": {
"jx:type": "reference",
"type": "defaultString",
"use": "optional",
"doc": "Optional property referencing 'defaultString' type"
},
"defaultStringOptionalNotNullable": {
"jx:type": "reference",
"type": "defaultString",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable property referencing 'defaultString' type"
},
"charArray": {
"jx:type": "reference",
"type": "charArray",
"doc": "Property referencing 'charArray' type"
},
"charArrayOptional": {
"jx:type": "reference",
"type": "charArray",
"use": "optional",
"doc": "Optional property referencing 'charArray' type"
},
"charArrayOptionalNotNullable": {
"jx:type": "reference",
"type": "charArray",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable property referencing 'charArray' type"
},
"uuid": {
"jx:type": "reference",
"type": "uuid",
"doc": "Property referencing 'uuid' type"
},
"uuidOptional": {
"jx:type": "reference",
"type": "uuid",
"use": "optional",
"doc": "Optional property referencing 'uuid' type"
},
"uuidOptionalNotNullable": {
"jx:type": "reference",
"type": "uuid",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable property referencing 'uuid' type"
},
"url": {
"jx:type": "reference",
"type": "url",
"doc": "Property referencing 'url' type"
},
"urlOptional": {
"jx:type": "reference",
"type": "url",
"use": "optional",
"doc": "Optional property referencing 'url' type"
},
"urlOptionalNotNullable": {
"jx:type": "reference",
"type": "url",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable property referencing 'url' type"
},
"StringBigDecimal": {
"jx:type": "reference",
"type": "StringBigDecimal",
"doc": "Property referencing 'StringBigDecimal' type"
},
"StringBigDecimalOptional": {
"jx:type": "reference",
"type": "StringBigDecimal",
"use": "optional",
"doc": "Optional property referencing 'StringBigDecimal' type"
},
"StringBigDecimalOptionalNotNullable": {
"jx:type": "reference",
"type": "StringBigDecimal",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable property referencing 'StringBigDecimal' type"
},
"nonEmptyString": {
"jx:type": "reference",
"type": "nonEmptyString",
"doc": "Property referencing 'nonEmptyString' type"
},
"nonEmptyStringOptional": {
"jx:type": "reference",
"type": "nonEmptyString",
"use": "optional",
"doc": "Optional property referencing 'nonEmptyString' type"
},
"nonEmptyStringOptionalNotNullable": {
"jx:type": "reference",
"type": "nonEmptyString",
"use": "optional",
"nullable": false,
"doc": "Optional, not-nullable property referencing 'nonEmptyString' type"
}
}
}
}
<schema
xmlns="http://www.jsonx.org/schema-0.4.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jsonx.org/schema-0.4.xsd http://www.jsonx.org/schema.xsd"
doc="Schema focusing on bindings">
<boolean name="StringBoolean">
<binding lang="java" type="java.lang.String"/>
</boolean>
<number name="short" scale="0" range="[-32768,32767]">
<binding lang="java" type="short"/>
</number>
<number name="StringDecimal">
<binding lang="java" type="java.lang.StringBuilder" decode="java.lang.StringBuilder.<init>"/>
</number>
<string name="uuid">
<binding lang="java" type="java.util.UUID" decode="org.libj.lang.Strings.toUuidOrNull"/>
</string>
<array name="arrayReferences">
<reference type="StringBoolean"/>
<reference type="short" nullable="false"/>
<reference type="StringDecimal"/>
<reference type="uuid"/>
</array>
<array name="arrayDirect">
<boolean>
<binding lang="java" type="java.lang.String"/>
</boolean>
<number scale="0" nullable="false">
<binding lang="java" type="short"/>
</number>
<number>
<binding lang="java" type="java.lang.StringBuilder" decode="java.lang.StringBuilder.<init>"/>
</number>
<string>
<binding lang="java" type="java.util.UUID" decode="org.libj.lang.Strings.toUuidOrNull"/>
</string>
</array>
<object name="objRefs">
<property name="arrayDirect" xsi:type="reference" type="arrayDirect">
<binding lang="java" field="objRefArrayDirect"/>
</property>
<property name="arrayReferences" xsi:type="reference" type="arrayReferences">
<binding lang="java" field="objRefArrayReferences"/>
</property>
<property name="StringBoolean" xsi:type="reference" type="StringBoolean">
<binding lang="java" field="objRefStringBoolean"/>
</property>
<property name="short" xsi:type="reference" type="short" nullable="false">
<binding lang="java" field="objRefShortPrimitive"/>
</property>
<property name="StringDecimal" xsi:type="reference" type="StringDecimal">
<binding lang="java" field="objRefStringDecimal"/>
</property>
<property name="uuid" xsi:type="reference" type="uuid">
<binding lang="java" field="objRefUuid"/>
</property>
<property name="object" xsi:type="reference" type="objRefs">
<binding lang="java" field="objRefObject"/>
</property>
</object>
<object name="objDir">
<property name="arrayDirect" xsi:type="array">
<boolean>
<binding lang="java" type="java.lang.String"/>
</boolean>
<number scale="0" nullable="false">
<binding lang="java" type="short"/>
</number>
<number>
<binding lang="java" type="java.lang.StringBuilder" decode="java.lang.StringBuilder.<init>"/>
</number>
<string>
<binding lang="java" type="java.util.UUID" decode="org.libj.lang.Strings.toUuidOrNull"/>
</string>
<binding lang="java" field="objDirArrayDirect"/>
</property>
<property name="arrayReferences" xsi:type="array">
<reference type="arrayDirect"/>
<reference type="arrayReferences"/>
<reference type="StringBoolean"/>
<reference type="short" nullable="false"/>
<reference type="StringDecimal"/>
<reference type="uuid"/>
<binding lang="java" field="objDirArrayReferences"/>
</property>
<property name="StringBoolean" xsi:type="boolean">
<binding lang="java" type="java.lang.String" field="objDirStringBoolean"/>
</property>
<property name="short" xsi:type="number" scale="0" nullable="false">
<binding lang="java" type="short" field="objDirShortPrimitive"/>
</property>
<property name="StringDecimal" xsi:type="number">
<binding lang="java" type="java.lang.StringBuilder" decode="java.lang.StringBuilder.<init>" field="objDirStringDecimal"/>
</property>
<property name="uuid" xsi:type="string">
<binding lang="java" type="java.util.UUID" decode="org.libj.lang.Strings.toUuidOrNull" field="objDirUuid"/>
</property>
<property name="object" xsi:type="object" extends="objDir">
<binding lang="java" field="objDirObject"/>
</property>
</object>
</schema>
{
"jx:ns": "http://www.jsonx.org/schema-0.4.jsd",
"jx:schemaLocation": "http://www.jsonx.org/schema-0.4.jsd http://www.jsonx.org/schema-0.4.jsd",
"doc": "Schema focusing on bindings",
"StringBoolean": {
"jx:type": "boolean",
"bindings": [{
"lang": "java",
"type": "java.lang.String"
}]
},
"short": {
"jx:type": "number",
"scale": 0,
"range": "[-32768,32767]",
"bindings": [{
"lang": "java",
"type": "short"
}]
},
"StringDecimal": {
"jx:type": "number",
"bindings": [{
"lang": "java",
"type": "java.lang.StringBuilder",
"decode": "java.lang.StringBuilder.<init>"
}]
},
"uuid": {
"jx:type": "string",
"bindings": [{
"lang": "java",
"type": "java.util.UUID",
"decode": "org.libj.lang.Strings.toUuidOrNull"
}]
},
"arrayReferences": {
"jx:type": "array",
"elements": [{
"jx:type": "reference",
"type": "StringBoolean"
}, {
"jx:type": "reference",
"type": "short",
"nullable": false
}, {
"jx:type": "reference",
"type": "StringDecimal"
}, {
"jx:type": "reference",
"type": "uuid"
}]
},
"arrayDirect": {
"jx:type": "array",
"elements": [{
"jx:type": "boolean",
"bindings": [{
"lang": "java",
"type": "java.lang.String"
}]
}, {
"jx:type": "number",
"scale": 0,
"nullable": false,
"bindings": [{
"lang": "java",
"type": "short"
}]
}, {
"jx:type": "number",
"bindings": [{
"lang": "java",
"type": "java.lang.StringBuilder",
"decode": "java.lang.StringBuilder.<init>"
}]
}, {
"jx:type": "string",
"bindings": [{
"lang": "java",
"type": "java.util.UUID",
"decode": "org.libj.lang.Strings.toUuidOrNull"
}]
}]
},
"objRefs": {
"jx:type": "object",
"properties": {
"arrayDirect": {
"jx:type": "reference",
"type": "arrayDirect",
"bindings": [{
"lang": "java",
"field": "objRefArrayDirect"
}]
},
"arrayReferences": {
"jx:type": "reference",
"type": "arrayReferences",
"bindings": [{
"lang": "java",
"field": "objRefArrayReferences"
}]
},
"StringBoolean": {
"jx:type": "reference",
"type": "StringBoolean",
"bindings": [{
"lang": "java",
"field": "objRefStringBoolean"
}]
},
"short": {
"jx:type": "reference",
"type": "short",
"nullable": false,
"bindings": [{
"lang": "java",
"field": "objRefShortPrimitive"
}]
},
"StringDecimal": {
"jx:type": "reference",
"type": "StringDecimal",
"bindings": [{
"lang": "java",
"field": "objRefStringDecimal"
}]
},
"uuid": {
"jx:type": "reference",
"type": "uuid",
"bindings": [{
"lang": "java",
"field": "objRefUuid"
}]
},
"object": {
"jx:type": "reference",
"type": "objRefs",
"bindings": [{
"lang": "java",
"field": "objRefObject"
}]
}
}
},
"objDir": {
"jx:type": "object",
"properties": {
"arrayDirect": {
"jx:type": "array",
"bindings": [{
"lang": "java",
"field": "objDirArrayDirect"
}],
"elements": [{
"jx:type": "boolean",
"bindings": [{
"lang": "java",
"type": "java.lang.String"
}]
}, {
"jx:type": "number",
"scale": 0,
"nullable": false,
"bindings": [{
"lang": "java",
"type": "short"
}]
}, {
"jx:type": "number",
"bindings": [{
"lang": "java",
"type": "java.lang.StringBuilder",
"decode": "java.lang.StringBuilder.<init>"
}]
}, {
"jx:type": "string",
"bindings": [{
"lang": "java",
"type": "java.util.UUID",
"decode": "org.libj.lang.Strings.toUuidOrNull"
}]
}]
},
"arrayReferences": {
"jx:type": "array",
"bindings": [{
"lang": "java",
"field": "objDirArrayReferences"
}],
"elements": [{
"jx:type": "reference",
"type": "arrayDirect"
}, {
"jx:type": "reference",
"type": "arrayReferences"
}, {
"jx:type": "reference",
"type": "StringBoolean"
}, {
"jx:type": "reference",
"type": "short",
"nullable": false
}, {
"jx:type": "reference",
"type": "StringDecimal"
}, {
"jx:type": "reference",
"type": "uuid"
}]
},
"StringBoolean": {
"jx:type": "boolean",
"bindings": [{
"lang": "java",
"type": "java.lang.String",
"field": "objDirStringBoolean"
}]
},
"short": {
"jx:type": "number",
"scale": 0,
"nullable": false,
"bindings": [{
"lang": "java",
"type": "short",
"field": "objDirShortPrimitive"
}]
},
"StringDecimal": {
"jx:type": "number",
"bindings": [{
"lang": "java",
"type": "java.lang.StringBuilder",
"field": "objDirStringDecimal",
"decode": "java.lang.StringBuilder.<init>"
}]
},
"uuid": {
"jx:type": "string",
"bindings": [{
"lang": "java",
"type": "java.util.UUID",
"field": "objDirUuid",
"decode": "org.libj.lang.Strings.toUuidOrNull"
}]
},
"object": {
"jx:type": "object",
"extends": "objDir",
"bindings": [{
"lang": "java",
"field": "objDirObject"
}]
}
}
}
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Special thanks to EJ Technologies for providing their award winning Java Profiler (JProfiler) for development of the JSONx Framework.
This project is licensed under the MIT License - see the LICENSE.txt file for details.