Tools, FAQ, Tutorials:
'type' - JSON Schema Validation Keyword
How to use the "type" JSON Schema validation keyword to validate JSON instances?
✍: FYIcenter.com
"type" is a generic JSON Schema validation keyword that always applied to the JSON instance.
When "type" is specified, the JSON instance must match one of the given JSON types: "null", "boolean", "object", "array", "number", "string", or "integer".
When "type" is given with a single JSON type, the JSON instance must match the given JSON types. For example, if {"type": "number"} is specified, the JSON instance must be a JSON Number value.
JSON Schema:
{"type": "number"}
Valid JSON instance:
0.314159E+01
Valid JSON instance:
314159
Invalid JSON instance:
"3.14159"
If {"type": "integer} is specified, the JSON instance must be a JSON Number presenting an integer. For example:
JSON Schema:
{"type": "integer"}
Valid JSON instance:
128
Invalid JSON instance:
0.314159E+01
If {"type": "string"} is specified, the JSON instance must be a JSON String value. For example:
JSON Schema:
{"type": "string"}
Valid JSON instance:
"Hello world!"
Valid JSON instance:
"3.14159"
Invalid JSON instance:
314159
If {"type": "array"} is specified, the JSON instance must be a JSON Array value. For example:
JSON Schema:
{"type": "array"}
Valid JSON instance:
[1,2,3]
Invalid JSON instance:
3.14159
If {"type": "object"} is specified, the JSON instance must be a JSON Object value. For example:
JSON Schema:
{"type": "object"}
Valid JSON instance:
{"age": 25}
Invalid JSON instance:
[1,2,3]
When "type" is given with an array of JSON types, the JSON instance must match one of the given JSON types. For example,
JSON Schema:
{"type": ["array", "object"]}
Valid JSON instance:
{"age": 25}
Valid JSON instance:
[1,2,3]
Invalid JSON instance:
0.314159E+01
⇒ Generic JSON Schema Validation Keywords
2017-08-25, ∼2584🔥, 0💬
Popular Posts:
What are the differences of Differences of evaluateTransaction() and submitTransaction() of the fabr...
What Azure AD App Registration Manifest? Azure AD App Registration Manifest is JSON file that contai...
What's Wrong with "while ($c=fgetc($f)) {}" in PHP? If you are using "while ($c=fgetc($f)) {}" to lo...
How to dump (or encode, serialize) a Python object into a JSON string using json.dumps()? The json.d...
What is EPUB 3.0 Metadata "dc:description" Element? EPUB 3.0 Metadata "dc:description" is an optiona...