Free Function: JSONGetElementInArray

JSONGetElementInArray will search through an array of uniform JSON objects until it finds a matching value in a specified key and then can return another key value or the entire object at the matching index location.


JSONGetElementInArray ( array ; searchKey ; searchValue ; resultKey )

Parameters

Click on a parameter to view the available options:

The array parameter must contain an array of uniform JSON objects. For example, an array of address components:

[ { “label” : “first” , “value” : “John” , }; { “label” : “last” , “value” : “Smith” , }; { “label” : “address” , “value” : “123 Back Avenue” , }; { “label” : “city” , “value” : “Somewhereville” , }; { “label” : “state” , “value” : “New York” , }; { “label” : “zip” , “value” : “10101” , } ]

The searchKey parameter must contain the name of a key that exists in every object in the array. For example, to search for a specific address component, the searchKey would be “label.”
The searchValue parameter must contain the value that the specified key must contain to form a match. For example, to search for the zip code in the array above, the searchKey would be “label” and the searchValue would be “zip.”
The resultKey parameter contains a text value specifying which attribute to return from the index position in which a search value match is found. An empty resultKey indicates that the entire object at the matching array position should be returned.

 

Download the Free Demo

The free downloadable Learn FileMaker JSONGetElementInArray demo file contains a working demo of the function and the ability to copy it into your database.

The demo contains the following layouts:

  1. Introducing the Function
  2. Defining the Function
  3. Sandbox Example
  4. Copy the Function

Download the free updated demo today and add the JSONGetElementInArray function to your database.

Download

FileMaker Pro 16 is required to view the demo.


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. The JSONGetRecord function is a custom function developed by Mark Conway Munro, author of Learn FileMaker Pro 16 (Apress, 2017).