You might have noticed that JSON has become a quite popular text format over the last years. Especially for everyone who is working in a Java environment. But how do you check your JSON instance documents in a convenient and standardized way like you can do for any XML file? For this purpose JSON Schema was introduced. In order to help people writing JSON schemas, XML ValidatorBuddy provides now special syntax-coloring for schema keywords and a built-in validator.
But how do you tell XML ValidatorBuddy that you are working on a JSON schema? Simply use the new “Quick Associations” pane which is available since version 4.3 and set the “Document is JSON Schema” checkmark. From this moment on the editor knows that this JSON file should be treated as JSON schema.
You will notice that the way JSON syntax-coloring works changes immediately after telling XML ValidatorBuddy that this JSON is actually a schema file. All of the schema keywords are now green and all of the keywords are also present in the auto-completion. Just take a look how the GeoJSON schema is displayed in the editor:
You can see that keywords like “properties” or “description” appear in green, while arbitrary names like “longitude” are still in red. This improves the readability of the schema file in the editor a lot.
Auto-completion is a very important feature and helps tremendously on creating and editing any text-based standard. As you can see on the screenshot below, XML ValidatorBuddy provides a list of JSON schema keywords also for the auto-completion window:
And how do I check my JSON instance document once the schema is ready? Simply enter the path to the JSON schema at the “JSON Schema” field of the “Quick Associations” pane when the JSON instance is the active document. Now the editor keeps a reference to the schema for this instance document. It is also possible to put a relative path here. So you can just enter the name of the schema, if both are located in the same folder. Whenever you use the “Validate against JSON Schema” command the schema content is either loaded from disk or directly taken from the editor and the validation results appear in the “Results” pane.