Brian Dunning's FileMaker Custom Functions

JSONExplode ( JSON )

Transforms JSON into a return-delimited list.

  Average rating: 5.0 (1 vote) Log in to vote

Julio Toledo   Julio Toledo - Show more from this author
Automation USA LLC
https://www.automationusa.net

Share on Facebook Share on Twitter

  Sample input:
{
"bakery" :
{
"product" :
[
{
"id" : "FB1",
"name" : "Donuts",
"price": 1.99,
"stock" : 43,
"category" : "Breads",
"special" : true
},
{
"id" : "FB2",
"price": 22.5,
"name" : "Chocolate Cake",
"stock" : 23,
"category" : "Cakes",
"special" : true
},
{
"id" : "FB3",
"price": 3.95,
"name" : "Baguette",
"stock" : 34,
"category" : "Breads",
"special" : true
}
]
}
}
  Sample output:
bakery:
product:
id:FB1
name:Donuts
price: 1.99
stock:43
category:Breads
special:true
id:FB2
price: 22.5
name:Chocolate Cake
stock:23
category:Cakes
special:true
id:FB3
price: 3.95
name:Baguette
stock:34
category:Breads
special:true

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

Transforms JSON into a return-delimited list similar to YAML.
This custom function is similar to ExplodeJSON (https://www.briandunning.com/cf/2028) with the following significant differences:
1. Preserves commas in JSON body (i.e. "location:San Jose, Central, CA" )
2. Removes "pretty print" formatting (i.e. "JSONFormatElements ( json )"
( https://fmhelp.filemaker.com/help/17/fmp/en/#page/FMP_Help%2Fjsonformatelements.html )

Example:
JSONExplode ( "{\"accountType\":\"CFD,ABC, DEF...\",\"accountInfo\":{\"balance\":22677.03,\"deposit\":16167.52,\"profitLoss\":-4199.32,\"available\":2310.19}" )

Returns:
accountType:CFD,ABC, DEF...
accountInfo:
balance:22677.03
deposit:16167.52
profitLoss:-4199.32
available:2310.19

 

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: