Brian Dunning's FileMaker Custom Functions

JSONArrayLength ( JSONArrayStr )

JSON Array Length

  Average rating: 4.5 (2 votes) Log in to vote

Rob Poelking   Rob Poelking - Show more from this author
Excelisys, Inc.

Share on Facebook Share on Twitter

  Sample input:
JSONArrayLength ( ~json )

JSONArrayLength ( "badjson" )

JSONArrayLength ( JSONGetElement ( JSONSetElement ( "" ; [ "this[0].name" ; "Brian"; "" ] ; [ "this.[0].last" ; "Dunning" ; "" ]) ; "this[0]" ) )
  Sample output:

invalid json


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

Returns the length (or count) of the elements in the JSON. This includes any keys not just arrays but it's particularly useful for looping over arrays to have the count of the objects.



Jared   Jared, Lethbridge
May 25, 2018
Why not add some error trapping? If the json is not valid it returns 4.
Also why not have an option for starting at 0. When indexing json 0 is the first number.
Rob   Rob, Monk Media
May 25, 2018
The idea of adding error trapping is a great suggestion, Jared. Thanks.

I don't start at zero because the point of the function is to report how many elements are contained in the JSON object or array. Zero should suggest that no elements are contained in the object.

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: