Tools, FAQ, Tutorials:
JSON Schema Syntax
What is the JSON Schema syntax? I heard that it is very simple.
✍: FYIcenter.com
JSON Schema syntax is very simple. Here are some basic JSON Schema syntax rules:
1. A JSON schema must be a valid JSON Object.
2. A JSON schema may contain zero, one or more validation properties (also called keywords). Each validation keyword represents a validation rule. A JSON value is considered to be valid against a JSON schema, it must pass all validation rules listed in the JSON schema.
For example, the following JSON schema has no validation rules given with any validation keywords, so any JSON value is considered as valid against this JSON schema:
{}
3. "type" is the most frequently used validation keyword, which represent a validation rule that requires the JSON value to match the given JSON type: "null", "boolean", "object", "array", "number", "string" or "integer".
For example, the following JSON schema requires the JSON value to be a JSON Number:
{
"type": "number"
}
3. "items" is a validation keyword that provides a child JSON schema or an array of child JSON schema to validate the array elements if the JSON value is a JSON array.
For example, the following JSON schema defines a JSON schema for a JSON Array of JSON Strings:
{
"type": "array",
"items": {
"type": "string"
}
}
4. "properties" is a validation keyword that provides an object with properties expected in the JSON Object value and child JSON schema for each property value.
For example, the following JSON schema defines a JSON schema for a JSON object with two properties "name" and "age". Both of them should be JSON String values.
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer"
}
}
}
5. "not" is a validation keyword that reverse the meaning of a child JSON schema.
For example, the following JSON schema makes any JSON value invalid, because {} is a schema that makes any JSON value valid.
{
"not": {}
}
2018-02-01, ∼2394🔥, 0💬
Popular Posts:
How to use urllib.parse.urlencode() function to encode HTTP POST data? My form data has special char...
How To Read Data from Keyboard (Standard Input) in PHP? If you want to read data from the standard i...
How To Avoid the Undefined Index Error in PHP? If you don't want your PHP page to give out errors as...
How to use "{{...}}" Liquid Codes in "set-body" Policy Statement? The "{{...}}" Liquid Codes in "set...
How to use the "set-variable" Policy Statement to create custom variables for an Azure API service o...