{"id":6,"date":"2022-10-04T09:03:38","date_gmt":"2022-10-04T09:03:38","guid":{"rendered":"https:\/\/www.json-buddy.com\/blog\/?p=6"},"modified":"2022-10-09T10:21:53","modified_gmt":"2022-10-09T10:21:53","slug":"configure-and-use-json-schema-pools-for-validation","status":"publish","type":"post","link":"https:\/\/www.json-buddy.com\/blog\/2022\/10\/04\/configure-and-use-json-schema-pools-for-validation\/","title":{"rendered":"Configure and use JSON schema pools for validation"},"content":{"rendered":"\n<p>The JSON schema standard does not define a way to reference local or remote schema files for validation from within the JSON instance document. A <strong>JSON validator<\/strong> needs to support a way to load and assign schemas to the JSON data. Just setting a single root schema is not sufficient, if the schema itself references other components with $ref and $id. A JSON schema is identified by its $id and not by a local or remote path (Uri).<\/p>\n\n\n\n<p>To address this, a <strong>schema pool can hold any number of JSON Schema files<\/strong>. One of those schemas is also set as the root schema in the configuration file.<\/p>\n\n\n\n<h3>Selecting a JSON Schema pool<\/h3>\n\n\n\n<p>In <a rel=\"noreferrer noopener\" title=\"Download JSON editor for Windows\" href=\"https:\/\/www.json-buddy.com\/json-editor-download.htm\" target=\"_blank\">JSONBuddy<\/a>, a schema for the active document can be selected using the Quick Associations pane. You can either set a pool or a local or remote path to the root schema as an alternative. If a schema pool is selected, the edit field to enter a path is disabled. The current schema pool assignment can be cleared with the red X button to the right.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"561\" height=\"329\" src=\"https:\/\/www.json-buddy.com\/blog\/wp-content\/uploads\/2022\/10\/image.png\" alt=\"\" class=\"wp-image-11\" srcset=\"https:\/\/www.json-buddy.com\/blog\/wp-content\/uploads\/2022\/10\/image.png 561w, https:\/\/www.json-buddy.com\/blog\/wp-content\/uploads\/2022\/10\/image-300x176.png 300w\" sizes=\"(max-width: 561px) 100vw, 561px\" \/><figcaption>Select a JSON Schema pool<\/figcaption><\/figure>\n\n\n\n<h3>The schema pools configuration file<\/h3>\n\n\n\n<p>All available JSON schema pools are configured using a settings document. This JSON file can be opened in JSONBuddy with the &#8220;Open config&#8230;&#8221; button. Add and edit the single pool entries directly in the JSON editor to change the configuration. Save the JSON file as usual and use the &#8220;Reload&#8221; button of the &#8220;Quick Associations&#8221; pane to apply the modifications to the schema pools used for JSON validation.<\/p>\n\n\n\n<p>Here is an example of a simple schema pools configuration file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;\n  {\n    \"id\": \"1948DF5D-0765-4939-9F88-64CD3BB1D306-0\",\n    \"title\": \"Library Example Schema\",\n    \"version\": 1,\n    \"rootIndex\": 0,\n    \"entries\": &#91;\n      \"SchemaPools\\\\Library\\\\library_schema_root.json\",\n      \"SchemaPools\\\\Library\\\\library_schema_book.json\"\n    ]\n  }  \n]<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Property<\/td><td>Type<\/td><td>Description<\/td><\/tr><tr><td><code>id<\/code><\/td><td><code>string<\/code><\/td><td>A unique identifier of the pool within this configuration file.<\/td><\/tr><tr><td><code>title<\/code><\/td><td><code>string<\/code><\/td><td>Title to be displayed.<\/td><\/tr><tr><td><code>rootIndex<\/code><\/td><td><code>integer<\/code><\/td><td>Zero-based index to set the root schema of this pool. If omitted, the first entry is taken as root schema.<\/td><\/tr><tr><td><code>entries<\/code><\/td><td><code>array<\/code><\/td><td>An array of strings with local or remote (Url) paths to the schema documents. For local paths, the entry can be a relative path with the configuration file as the base.<\/td><\/tr><\/tbody><\/table><figcaption>Properties of a JSON schema pool entry.<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The JSON schema standard does not define a way to reference local or remote schema files for validation from within the JSON instance document. A JSON validator needs to support a way to load and assign schemas to the JSON data. Just setting a single root schema is not sufficient, if the schema itself references &hellip; <a href=\"https:\/\/www.json-buddy.com\/blog\/2022\/10\/04\/configure-and-use-json-schema-pools-for-validation\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Configure and use JSON schema pools for validation<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[3,4],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/posts\/6"}],"collection":[{"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/comments?post=6"}],"version-history":[{"count":5,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/posts\/6\/revisions"}],"predecessor-version":[{"id":12,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/posts\/6\/revisions\/12"}],"wp:attachment":[{"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/media?parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/categories?post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.json-buddy.com\/blog\/wp-json\/wp\/v2\/tags?post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}