Working with JSON Pointers
In 4D v16 R4, we enriched object commands so you can validate JSON objects. 4D v16 R5 is going even further by introducing the support of JSON pointers. Great – but what is a JSON pointer and what can I do with it?
Just like you don’t store company details for each employee in a database record (using a link to the company record instead), it can be really useful to structure a JSON document with parts that can be reused in a number of places.
For instance, let’s take an example of a website order; the customer enters the shipping address and designates the billing address as the same. Instead of duplicating the address information, we can define the shipping address as a reference to the the billing address.
A new tool: JSON Validator
4D v16 R4 introduces a new command: JSON Validate. This command allows you to verify that a JSON document is “valid” according to your JSON schema. This is really useful for exchanging information between servers or between a server and its client. Thanks to JSON schema standards, you can define a “protocol” for communication with your server or an external server. More details can be found in this blog post.
Validate your JSON object
We use more and more the JSON format. For example, to save settings in a file, to store software configuration, or to exchange client-data on the web with other servers.
How can you validate that the received data is in the expected format? How can you validate that all the necessary information is actually present? How can you do this validation without writing a tiresome method for each type of JSON format?
Simply by writing a JSON schema and use the JSON Validate new command!