225
edits
(Install package: OSW Docs - Core) |
m (Protected "JSON-SCHEMA Tutorial": Protected as read-only import via Page Exchange extension ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) [cascading]) |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 126: | Line 126: | ||
==JSON-SCHEMA: Reference== | ==JSON-SCHEMA: Reference== | ||
How to define a JSON-SCHEMA? | How to define a JSON-SCHEMA? | ||
*We want to | *We want to leverage the power of typing and validation | ||
*Therefore, our defined key(word):value pairs need to become JSON objects, specifying a type! | *Therefore, our defined key(word):value pairs need to become JSON objects, specifying a type! | ||
*JSON (object) properties posses a keyword, which is used for reference | *JSON (object) properties posses a keyword, which is used for reference | ||
| Line 572: | Line 572: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</div> | |||
==JSON-SCHEMA: References and Pointers == | |||
JSON Pointers and References can be used to reuse schema definitions [https://json-schema.org/understanding-json-schema/structuring] | |||
<div style="column-count: 3;"> | |||
<div style="break-inside: avoid;"> MyCommonSchema.json | |||
<syntaxhighlight lang="json"> | |||
{ | |||
"type": "object", | |||
"properties": { | |||
"text": { "type": "string" }, | |||
"number": { "type": "number" }, | |||
"array": { "type": "array" } | |||
} | |||
} | |||
</syntaxhighlight> | |||
</div> | |||
<div style="break-inside: avoid;"> MySchema.json | |||
<syntaxhighlight lang="json"> | |||
{ | |||
"type": "object", | |||
"allOf": {"$ref": "MyCommonSchema.json"}, | |||
"$defs": { | |||
"name": { "type": "string" } | |||
}, | |||
"properties": { | |||
"my_property": { "$ref": "#/$defs/name" } | |||
} | |||
} | |||
</syntaxhighlight> | |||
</div> | |||
<div style="break-inside: avoid;"> Result | |||
<syntaxhighlight lang="json"> | |||
{ | |||
"type": "object", | |||
"properties": { | |||
"text": { "type": "string" }, | |||
"number": { "type": "number" }, | |||
"array": { "type": "array" }, | |||
"my_property": { "type": "string" } | |||
} | |||
} | |||
</syntaxhighlight> | |||
</div> | |||
</div> | </div> | ||
==JSON Documents: Next== | ==JSON Documents: Next== | ||
*[[Item:OSW911488771ea449a6a34051f8213d7f2f]] [{{fullurl:Item:OSW911488771ea449a6a34051f8213d7f2f|reveal=true}} Slideshow] | *[[Item:OSW911488771ea449a6a34051f8213d7f2f]] [{{fullurl:Item:OSW911488771ea449a6a34051f8213d7f2f | ||
|reveal=true | |||
}} Slideshow] | |||
| jsondata | |||
|---|---|---|---|
| Line 1: | Line 1: | ||
{ | { | ||
"required_predecessor": [ | |||
"Item:OSWf1df064239044b8fa3c968339fb93344" | |||
], | |||
"type": [ | |||
"Category:OSW494f660e6a714a1a9681c517bbb975da" | |||
], | |||
"uuid": "f4a9514b-aed0-4859-a4c6-c374a7312f10", | |||
"name": "JsonSchemaTutorial", | |||
"label": [ | |||
{ | |||
"text": "JSON-SCHEMA Tutorial", | |||
"lang": "en" | |||
} | |||
], | |||
"image": "File:OSW7ab0a0b8aaa34217bff6cf9e97988c4d.png", | |||
"recommended_successor": [ | |||
"Item:OSW911488771ea449a6a34051f8213d7f2f", | |||
"Item:OSWee501c0fa6a9407d99c058b5ff9d55b4" | |||
] | |||
} | } | ||