Custom formats for the JSON validator

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:

Commands for JSON custom formats
Commands for JSON custom formats

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:

[
  {
    "format": "my-custom-format",
    "regex": "^[a-z, A-Z, /]+$"
  }
]

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:

library example with custom format definition
library example with custom format definition

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.