Brian Dunning's FileMaker Custom Functions

JSON.RemoveEmptyObjects ( obj )

Recursively remove empty objects like "{}" from a json object

  Be the first to rate this function Log in to vote

Josh Willing   Josh Willing - Show more from this author
Willing Apps

  Sample input:
{
"Admin":{
"a":123,
"b": {}
},
"User":{
"a":{
"b":{},
"c":{}
}
}
}
  Sample output:
{
"Admin":{"a":123}
}
// "User" completely removed because all nested objects
// Admin.b removed because empty obj

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

If removing an empty object in a nested key causes the parent object to become empty, the parent object will be removed too.

 

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 22 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: