Build JSONGetElement Path
A free database demonstrates how to format a path that references a nested JSON object value.
JSON functions were introduced in FileMaker 16 as a subset of Text Functions. These functions create and manipulate JSON objects, which contain multiple pieces of data stored in a structured text format sometimes referred to as an array or record.
About the JSONGetElement function
The JSONGetElement function is used to extract a value from for a specified key within a JSON object. The key specified can be either a key, and index or a path. This latter allows a single command to traverse down through multiple steps in the object’s hierarchy to identify a desired nested value.
Difficulty Referencing a Deeply Nested Value
Formulating a path through complex objects may at first seem confusing especially when it involves a combination of list arrays of structured objects. In such a case, some path elements will specify a key while others will specify the index position of an object in a list. This examples shows a hypothetical keyOrIndexOrPath parameter that will retrieve the name of the first contact (index position 0) in Ohio in the United States from an object stored in a variable called $jsonContacts:
JSONGetElement ( $jsonContacts ; "US.OH..name" )
When an object contains many nested layers, it can become confusing trying to parse out a particular value, especially for those unfamiliar with the format.
Download the Free Tool
The free downloadable Learn FileMaker JSONGetElement tool will help construct a keyOrIndexOrPath value by automatically guiding you down through the hierarchy of any JSON object. Each key available at a given level is displayed as a button. When clicked, the selected key or index position will be appended to a growing path, gradually drilling down through the structure of the object. Once the desired value is reached, the statement can be copied to the clipboard and pasted into your database.
Download the free tool today and get familiar with the format of a keyOrIndexOrPath parameter for the JSONGetElement function.
Updated January 19, 2018 to correct a bug when a key had a number as part of its name.
FileMaker Pro 16 is required to view the demo.