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 other components with $ref and $id. A JSON schema is identified by its $id and not by a local or remote path (Uri).
To address this, a schema pool can hold any number of JSON Schema files. One of those schemas is also set as the root schema in the configuration file.
Selecting a JSON Schema pool
In JSONBuddy, 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.
The schema pools configuration file
All available JSON schema pools are configured using a settings document. This JSON file can be opened in JSONBuddy with the “Open config…” 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 “Reload” button of the “Quick Associations” pane to apply the modifications to the schema pools used for JSON validation.
Here is an example of a simple schema pools configuration file:
You are not only looking for the best JSON editor for data files and JSON schemas? You are working on a Windows system and you need to quickly validate one or multiple JSON data files from the command-line? Then you should try the free JSON validator command-line tool for Windows from json-buddy.com.
Check one or multiple JSON documents against a JSON schema with a single line from the Windows shell.
Get a comprehensive validation report with a detailed error message and full location information as JSONPointer.
Support for the popular JSON Schema draft 4, draft 6 and draft 7 (Update: Support for draft 2019-09 was added in the meantime).
Easy to use installer package. No additional configuration is required.
Free for commercial and personal use. Just request a free license after the 14-day evaluation period.
Please note that the tool also supports XML validation against a W3C schema. To get a complete list of switches, execute valbuddy.exe from the installation folder without any parameters.
Enhanced batch validation using a configuration file for simple folder validation and log file creation requires a license for JSONBuddy or XML ValidatorBuddy.
The JSON schema specification defines no way to assign a schema to a JSON data file. The schema used for validation is either set by the application or by any meta-data like transmission headers or even filename patterns. As an editor for JSON schema, JSONBuddy needs to support methods to assign a JSON schema to the JSON data you are currently working on. Here are some ways to set the schema for your data:
Assign a local schema file using the “Quick associations” pane
The most straightforward way is to use the “Quick associations” pane of the editor to select a local JSON schema file from disk for the current document. This assignment is saved and restored the next time you open the instance in the JSON editor.
Open a JSON schema from schemastore.org and automatically generate sample data
This method is explained in more detail in this article. You can use the “Open from JSON schema library…” dialog in the editor to automatically generate sample data from any schema available at schemastore.org. The schema is also assigned to the generated JSON instance.
The file-name is matching a specific pattern
A lot of entries in the JSON schema library available at schemastore.org are also defining a file-name pattern which is used to load a schema from the library to validate the JSON data. For example, if you load a JSON document with the name “test.bower.json” the data is recognized as “Bower package description file” and you get the following message in the results window of the editor:
Generate sample data from any JSON schema
As a quick way to get a JSON instance from any schema use the command to generate sample JSON data. This way a new document is created in the editor and the source schema is also assigned in a single step.
Do you want to quickly generate a basic JSON schema in your editor from any JSON input to avoid some typing that needs to be done every time you start writing a schema? A quick skeleton schema as a starting point with all current properties defined and their integral types already resolved? If yes, you can do this in JSONBuddy with ease.
This is how you do it in the editor:
Open your JSON data as document. It doesn’t matter if you use the text or grid view.
Use the following command to open a new document with the generated JSON schema: “JSON | Generate JSON schema from document”.
The generated schema is opened as a new document in the editor. Integral types are resolved and all objects which are not part of the top level are added as definitions to the schema. Equal object definitions will only appear once.
Automatic schema generation in the background
But even if you don’t use the command to generate a schema, a JSON schema is automatically generated in the background for any JSON document with currently no schema assigned. This schema is used to fill the Elements pane and to provide the entry-helper windows.
Starting with JSONBuddy 4.6, you can add custom formats for the JSON validator as regular expressions using a simple configuration file. The JSON editor has got two new commands to give you easy access to this new functionality:
How to add and use custom formats?
Use the “Open JSON validator custom formats” command to open the JSON configuration file for custom formats directly in JSONBuddy. This is a standard JSON document and the default one will be loaded in the editor. You can then add your own entries to the JSON array for your validation tasks. Please note that you can also replace some existing formats which are already provided by the JSON validator of JSONBuddy. A user-defined format will override the built-in definition.
The standard configuration has the following entry:
As you can see all you need to do is to provide two simple strings to add a custom format. The identifier of the new format and a (valid) regular expression. After you have finished adding your new entries you simply save the configuration file and activate the new formats with the “Reload JSON validator custom formats” command. All open JSON documents are immediately validated using the new format definitions.
You can also see the names of your own formats on editing your JSON data in the editor:
The “library” example, which is part of the standard installation, also uses a custom format. Just check it out and play around with different regular expressions.
JSONBuddy continues to extend the support for JSON schema and fully supports draft 6 as the only available JSON schema editor. From now on (JSONBuddy 4.6), you can validate your JSON files against draft 6 directly in the editor. In addition, you can also start using draft 6 in the command-line tool, which is part of the JSONBuddy software package, to run your batch validation tasks.
JSON schema draft 6 is supported by the following components in detail
JSON validator – Also available for background validation and live error indicators in text view
JSON schema editor – Full entry-helper support for new draft 6 keywords, schema validation and schema specification as help text.
With JSON schema draft 6 and the integrated easy access to the schemastore.org schema library, JSONBuddy provides the most comprehensive support for JSON schema available. And JSONBuddy will also continue to implement the latest versions of the JSON schema standard in the future.
Are you tired of clicking the “Validate” button or pressing F11 every time you want to know if your JSON data has still some validation errors? Then there is the good news. With JSONBuddy 4.5 you don’t need to run the JSON validator explicitly anymore while you are working on your JSON data in the editor. Instead, you always get all issues displayed as text indicators instantaneously and directly in the JSON editor. You also get the error message shown as call-tip if you hover with the mouse over the indicator for a short while:
Instant validation at any time
This allows a new way of working with JSON documents in JSONBuddy. You just open the JSON and if there is already a schema assigned, you can immediately see if the JSON data has errors or not. And to make it easier to fix any issues and to know what values are actually available for the enumeration, the editor will also display an entry-helper if you are going to fill the property:
So in summary, you always see any errors immediately and you get instant help if you want to fix them in the editor while you are editing your JSON data. Both make working with JSON more convenient and help to save time. Two important things to provide the best JSON editor experience possible.
Ok, please don’t take this title literally. But did you know that you can instantly load all JSON schema files from schemastore.org in JSONBuddy? All you need to do is to open JSONBuddy and to use the “File | Open from JSON schema library…” command to show the open dialog which reads all available schema documents from schemastore.org. This list is updated any time you start the JSONBuddy editor.
schemastore.org is a great resource to learn how others are writing JSON schemas and can help a lot on providing own specifications for your JSON data. After the schema is loaded in JSONBuddy, the editor will automatically generate JSON sample data. You can immediately create a new document from the sample data using the “JSON | Generate sample document from JSON schema” command.