KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Intricacies JSON Validate Command
PRODUCT: 4D | VERSION: 16R4 | PLATFORM: Mac & Win
Published On: September 21, 2017

4Dv16R4 introduces a new command JSON Validate. This is a powerful command validates a 4D Object against a JSON schema to see if it passes the schema, or if it fails against the schema and that is it. Looking at the name in a broad sense there may be some assumptions made about how the command can work. Below are some clarifications on the command.

This command does not check if the contents of text type variables are valid JSON. This can be done with the following Tech Tip:
How to check if TEXT is an OBJECT / JSON


The command will fail against JSON Arrays for example:

$textVar:="[{\"Name\": \"Value\"}]"
$objectVar:=JSON Parse($textVar)
$resultVar:=JSON Validate($objectVar;"{}")

will generate the following error: