'Json $schema only works on root object

I'm trying to use the $schema property in a json file to point to a local json schema file. This works if I do it at the root:

enter image description here

But doesn't work if it is applied to any other element not at the root:

enter image description here

Is there a way to make this work when not applying the schema to the root?



Solution 1:[1]

No. The JSON Schema specification doesn't permit this.*

Why do you want to do this? The $schema keyword is declaring the syntax to use for the entire schema. It doesn't make sense to change that halfway through.

* Technically you can use the $schema keyword at any place that is known as a "resource root", but if you don't know what that is, you shouldn't be making use of that feature as it's rather advanced.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ether