Brian Dunning's FileMaker Custom Functions

JSONExplore ( json ; endpoint )

This is a helper function that I use all the time to help me explore and navigate unfamiliar JSON objects in situations such as exploring returned api results in a data viewer. The keys at the given endpoint are listed at the top. The formatted structure is listed next, and then the raw structure is listed last.

  Average rating: 5.0 (1 vote) Log in to vote

Robert D Trammel   Robert D Trammel - Show more from this author
Harmonic Software Production Studios

Share on Facebook Share on Twitter

  Sample input:
JSONExplore ( $json ; "" )
  Sample output:
==== Keys ====

==== Structure ====
"name" : "Beyonce Knowles"
"uid" : "1"

==== Data ====
"" = {"name":"Beyonce Knowles","uid": "1"}

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

If you pass in a blank string, it will get the keys at the top level and display the whole object. The idea here is that for each endpoint you want to step into you would just add a period and then the next key in the current key list.

For Example:
1st iteration
JSONExplore ( data ; "" )

==== Keys ====

2nd iteration
JSONExplore ( data ; "users" )

==== Keys ====

3rd iteration
JSONExplore ( data ; "users[0]" )

==== Keys ====

From there you can set up your script or while loop to loop through the array and easily process the data into your solution.

For example you might do:
$keys = JSONListKeys ( data ; "users" );
$keyLn = ValueCount ( $keys );
Exit Loop If [ Let ( $I = $I + 1 ; $I > $keyLn )
Set Variable [ $endpoint ; "users[" & GetValue ( $keys ; $I ) & "]" ]
Set Variable [ $name ; JSONGetElement ( data ; $endpoint & ".name" ) ]
Set Variable [ $id ; JSONGetElement ( data ; $endpoint & ".id" ) ]
End Loop



Robert D Trammel   Robert D Trammel, Harmonic Software Production Studios
Dec 7, 2021
Note to other developers, I tried to make it so that once you reach your final endpoint, the output is the exact calculation you would need to copy/paste into whatever process you were writing. So for instance, once you land on users[0].name, instead of seeing the entire keys/formatted/raw output, you would see JSONGetElement ( data ; "users[0].name" ) and then its output. This worked well when the input was a field because I could just do GetFieldName. However, when the input was a variable, there was no apparent way to do like a GetVariableName function. As a result, the output would just break, so I cleaned that out entirely but I'm still holding out hope that someone here either has, or will figure it out. Please keep me posted if that happens.

Log in to post comments.


Note: these functions are not guaranteed or supported by Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 16 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: