JSONArrayLength ( JSONArrayStr )
JSON Array Length
Average rating: 4.5 (2 votes) Log in to vote
Rob Poelking - Show more from this author
Kiza Solutions https://kizasolutions.com |
JSONArrayLength ( "badjson" )
JSONArrayLength ( JSONGetElement ( JSONSetElement ( "" ; [ "this[0].name" ; "Brian"; "" ] ; [ "this.[0].last" ; "Dunning" ; "" ]) ; "this[0]" ) )
invalid json
2
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.
Comments
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, 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. |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.