Brian Dunning's FileMaker Custom Functions

JSONDeleteEmptyElements ( json )

Removes any empty values from a JSON object or array of objects

  Be the first to rate this function Log in to vote

Jake Scheele   Jake Scheele - Show more from this author
Edimate
http://www.edimate.com

Share on Facebook Share on Twitter

  Sample input:
JSONFormatElements ( JSONDeleteEmptyElements ( JSONSetElement ( "{}"
;[ " empty" ; "" ; 1 ]
;[ "full" ; "full" ; 1 ]
;[ "object.empty" ; "" ; 1 ]
;[ "object.full" ; "full" ; 1 ]
;[ "arrayofObjects[0]empty" ; "" ; 1 ]
;[ "arrayofObjects[0]full" ; "full" ; 1 ]
;[ "arrayofObjects[1]empty2" ; "" ; 1 ]
;[ "arrayofObjects[1]full2" ; "full" ; 1 ]
;[ "arrayofObjects[1]tester" ; "" ; 1 ]
;[ "array[0]" ; "1" ; 1 ]
;[ "array[1]" ; "2" ; 1 ]
;[ "array[2]" ; "" ; 1 ]
;[ "array[3]" ; "4" ; 1 ]
) ) )
  Sample output:
{
"array" : [ 1, 2, "", 4 ],
"arrayofObjects" :
[
{
"full" : "full"
},
{
"full2" : "full"
}
],
"full" : "full",
"object" :
{
"full" : "full"
}
}

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

Removes any empty elements from a JSON object or array of objects. Recursively removes any empty nested values.

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. 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 20 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: