Draft:JSON Schema
Submission declined on 30 March 2025 by Sophisticatedevening (talk).
Where to get help
How to improve a draft
You can also browse Wikipedia:Featured articles and Wikipedia:Good articles to find examples of Wikipedia's best writing on topics similar to your proposed article. Improving your odds of a speedy review To improve your odds of a faster review, tag your draft with relevant WikiProject tags using the button below. This will let reviewers know a new draft has been submitted in their area of interest. For instance, if you wrote about a female astronomer, you would want to add the Biography, Astronomy, and Women scientists tags. Editor resources
| ![]() |
![]() | |
Filename extension |
.schema.json, .json |
---|---|
Internet media type |
application/schema+json |
Developed by | JSON Schema Working Group |
Type of format | Data interchange format |
Extended from | JSON |
Standard | Draft 2020-12 |
Open format? | Yes |
Website | json-schema |
JSON Schema is a specification for defining the structure and constraints of JSON (JavaScript Object Notation) data. It allows for validation, documentation, and interaction control of JSON-based formats, making it widely used in API development, data validation, and configuration management.[1]
Overview
[edit]JSON Schema provides a declarative way to describe JSON data. It enables validation by defining expected properties, types, formats, and constraints. JSON Schema is widely used to enforce consistency in data structures and improve interoperability between systems.[2]
Example
[edit]A sample JSON document and its schema:
JSON Data:
{
"productId": 1,
"productName": "A green door",
"price": 12.50,
"tags": ["home", "green"]
}
JSON Schema:
{
"$schema": "http://json-schema.org/draft/2020-12/schema",
"title": "Product",
"type": "object",
"properties": {
"productId": { "type": "integer" },
"productName": { "type": "string" },
"price": { "type": "number", "minimum": 0 },
"tags": { "type": "array", "items": { "type": "string" } }
},
"required": ["productId", "productName", "price"]
}
Features
[edit]Data Validation
[edit]JSON Schema validates data against predefined rules:
{
"type": "string",
"minLength": 5,
"pattern": "^[A-Z][a-z]+$"
}
This schema ensures a string starts with a capital letter, followed by lowercase letters, with minimum length of 5 characters.
Documentation
[edit]JSON Schema provides self-documenting metadata:
{
"title": "User",
"description": "A user account in the system",
"properties": {
"username": {
"description": "Unique identifier for the user"
}
}
}
The title, description, and property descriptions help developers understand the data structure.
Hypermedia Support
[edit]JSON Hyper-Schema extends JSON Schema for hypermedia-driven APIs:
{
"links": [
{
"rel": "self",
"href": "/users/{id}",
"templateRequired": ["id"]
}
]
}
This defines a link relation that constructs URLs using instance data, enabling HATEOAS principles.
Interoperability
[edit]JSON Schema works across different programming languages.
A schema could be emitted by a library in one programming language, and used for validation in a different programming language.
Versions
[edit]JSON Schema has undergone multiple revisions:
- Draft 4 (2013) – First widely adopted version.
- Draft 6 (2017) – Introduced new keywords and enhanced validation.
- Draft 7 (2018) – Added support for complex validation scenarios.
- Draft 2019-09 (2019) – Introduced dynamic references and new annotation features.
- Draft 2020-12 (2020) – The latest version, refining features and improving interoperability.[3]
Implementations
[edit]JSON Schema is supported in various programming languages:
- Python: The 'jsonschema' library provides validation capabilities.[4]
- JavaScript: The Ajv library offers efficient JSON Schema validation.[5]
- Java: Libraries such as Everit JSON Schema enable schema validation in Java applications.[6]
Applications
[edit]JSON Schema is commonly used in:
- API Development: Ensures consistency in request and response formats.
- Configuration Management: Validates configuration files for correctness.
- Data Storage: Helps define structured data models in NoSQL databases.[7]
Tools
[edit]Several tools facilitate working with JSON Schema:
- JSON Schema Validator: Online tool for validation.[8]
- JSON Builder: Interactive tool for creating and testing JSON structures.[9]
See also
[edit]References
[edit]- ^ "JSON Schema". json-schema.org. Retrieved 2025-03-30.
- ^ "What is a schema?". json-schema.org. Retrieved 2025-03-30.
- ^ "JSON Schema Specification". json-schema.org. Retrieved 2025-03-30.
- ^ "jsonschema". Python Package Index. Retrieved 2025-03-30.
- ^ "Ajv JSON Schema Validator". Retrieved 2025-03-30.
- ^ "Everit JSON Schema". GitHub. Retrieved 2025-03-30.
- ^ "JSON Schema Examples". MongoDB. Retrieved 2025-03-30.
- ^ "JSON Schema Validator". Newtonsoft. Retrieved 2025-03-30.
- ^ "JSON Builder". Retrieved 2025-03-30.
- Promotional tone, editorializing and other words to watch
- Vague, generic, and speculative statements extrapolated from similar subjects
- Essay-like writing
- Hallucinations (plausible-sounding, but false information) and non-existent references
- Close paraphrasing
Please address these issues. The best way to do it is usually to read reliable sources and summarize them, instead of using a large language model. See our help page on large language models.