JSON : Using the dot "." as a key element with FileMaker's JSON functions
In FileMaker's JSON function the dot "." is used as a delimiter to navigate between a JSON structure's elements.
But how to use the dot "." inside a key without having FileMaker interprates it as a delimiter ?
Ex :{"a.b":1}
Let's take a simple exemple
Here is the following JSON structure inside a $json variable :
{"a":{"b":1}}
To retrieve the value 1 from the b key we use JSONGetElement function like this :
JSONGetElement ( $json ; "a.b" )
Now, how is it possible to retrieve the value 1 inside this JSON structure :
{"a.b":1}
The string "a.b" needs to be placed between brackets and simple quotes : ['a.b'].
Because we are at the JSON object's root, we need to add a dot "." at the beggining of the string.
The formula becomes :
JSONGetElement ( $json ; ".['a.b']" )
As well, to create the previous structure with the function JSONSetElement the following syntax is working :
JSONSetElement ( "" ; ".['a.b']" ; 1 ; JSONNumber )