Altova XMLSpy 2025 Professional Edition

In the same way that an XML Schema specifies the structure and content of an XML document, a JSON schema specifies how the JSON data in a JSON document is organized. It specifies what data fields are expected and how the values are represented. The JSON Schema specification and more information about JSON Schema is available here.

 

A JSON schema is itself a JSON object. Lexically, the entire schema is contained within curly braces (see listing below), which are the delimiters of JSON objects. The schema is written in JSON syntax and will be saved typically in a file with a .json extension. It is indicated as a JSON schema, by the $schema keyword, which should be the first keyword of the top-level object. This keyword should have a value that is one of the following:

 

Versions to draft-07: "http://json-schema.org/draft-N/(hyper-)schema#", where N is the number of the version (04, 06, or 07).

Versions from draft-2019-09 onwards: "https://json-schema.org/draft/YYYY-MM/(hyper-)schema", where YYYY and MM are, respectively, the year and month of the draft, for example, 2019-09.

 

Here is an example of how the $schema keyword is used.

 

{

  "$schema": "https://json-schema.org/draft/2020-12/schema",

  ...

}

 

Note:Although the $schema keyword can have the value "http://json-schema.org/schema#"—which specifies the latest version of the schema—it is best to use a URL that identifies the specific version. For more information, see JSON Schema Version.  

 

 

In XMLSpy, you can create JSON schemas graphically in JSON Schema View. How to do this is described in the section JSON Schema View. Besides the schema editing features available in JSON Schema View, the following schema-related features are available:

 

Validation with the JSON Validator of XMLSpy: Assign a JSON schema to a JSON instance document, and validate the instance document from within XMLSpy. See Validating JSON Documents for information.

Setting JSON validation options.

Generating JSON Schema from a JSON Instance: If a JSON instance document already exists, you can generate a JSON schema from it. You can subsequently edit the schema if you need to.

Converting between JSON and XML: You can convert between documents of the two formats.

 

Terminology

Given below are definitions of common JSON schema terms used in the GUI and this documentation.

 

Term

Definition

Schema

The top-level schema object in a JSON schema document; the schema file.

Object

A JSON type containing zero or more properties.

Property

A key:value pair of an object. Its value can be any JSON datatype.

Keyword

The key part of an object's key:value pair. It is always a string.

Sub-schema

An object that is a child of an operator or a dependency.

Definition

The complete description of any JSON type. Definitions can be global or local.

Array

A comma-separated ordered list of zero or more items of any JSON datatype.

Atomic types

The string, number, integer, boolean, and null JSON datatypes.

Type selectors

The any and multiple types, which select any and multiple types, respectively

Operators

Occurrence selectors that can be added as children of definitions. See the section Operators.

 

JSON data types

Object property values and array items can be of the following types:

 

string (must be enclosed in quotes). A string can additionally be specified to have a format, such as a date-time or email format

number: A number with a fractional part; it includes integers

integer: A number with no fractional part; a subset of the number type

boolean (true/false, not enclosed in quotes)

object: When used within another object, allows data to be nested

array: Provides the ability to build more complex structures than allowed by objects

null (null, not enclosed in quotes)

 

© 2018-2024 Altova GmbH