Brian Dunning's FileMaker Custom Functions

JSONReadable ( JSON )

Make larger JSON objects and arrays readable

  Be the first to rate this function Log in to vote

David A Sullivan   David A Sullivan - Show more from this author
Mandelbrot LLC
http://mandelbrotllc.com

Share on Facebook Share on Twitter

  Sample input:
JSONReadable($json)

where $json =
{
"messages" :
[
{
"code" : "0",
"message" : "OK"
}
],
"response" :
{
"data" :
[
{
"fieldData" :
{
"ID" : "FB1",
"Name" : "Donuts",
"Stock" : 43
},
"modId" : "6",
"portalData" : {},
"recordId" : "1"
}
],
"dataInfo" :
{
"database" : "Favorite Bakery",
"foundCount" : 3,
"layout" : "Products",
"returnedCount" : 1,
"table" : "Products",
"totalRecordCount" : 3
}
}
}
  Sample output:
{"messages" : [
{"code" : "0",
"message" : "OK" }],
"response" : {"data" : [
{"fieldData" : {"ID" : "FB1",
"Name" : "Donuts",
"Stock" : 43 },
"modId" : "6",
"portalData" : {},
"recordId" : "1" }],
"dataInfo" : {"database" : "Favorite Bakery",
"foundCount" : 3,
"layout" : "Products",
"returnedCount" : 1,
"table" : "Products",
"totalRecordCount" : 3 } } }

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

Instead of having to copy/paste the value into a larger JSON editor when debugging or viewing JSON fields, use this function to condense the JSON down to a human-readable format.

After you get a few layers deep into arrays and objects, the spacing after the leftmost bracket can get a bit wonky. I'm open to suggestions as to how to fix that.

Aside from that one little cosmetic issue, the JSON it gets is the JSON you see.

 

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: