The Original Filemaker Community - Forum
FileMaker News | FileMaker Tutorials | FileMaker Videos

The Leading Filemaker Developer Tools

Password protection and security…

JSON Path Parsing in FIleMaker 16

This is not just any blog…this is an affiliate feature blog from the Scarpetta Group! Have you ever been given a huge block of nested JSON, or you are playing around with an API and you would like to see the keys for what is being returned?

With the introduction of FileMaker 16’s JSON functions and a single script you can get a list of all the unique paths down to each key value pair. This is a recursive script that drills down and generates a list of unique keys based on the JSON it is evaluating.

Example:

  • .QueryResponse.Customer[0].Taxable
  • .QueryResponse.Customer[0].domain
  • .QueryResponse.Customer[0].sparse
  • .QueryResponse.Customer[6].Fax
  • .QueryResponse.Customer[6].Fax.FreeFormNumber
  • .QueryResponse.Customer[6].Mobile
  • .QueryResponse.Customer[6].Mobile.FreeFormNumber
  • .QueryResponse.Customer[6].WebAddr
  • .QueryResponse.Customer[6].WebAddr.URI
  • .QueryResponse.Customer[7].Level
  • .QueryResponse.Customer[7].ParentRef
  • .QueryResponse.Customer[7].ParentRef.value
  • .QueryResponse.Customer[20].MiddleName

The example above is a snippet of the path list that was returned from the script. As we can see above each value is unique. Taxable is found in the first array of customers ( index 0 ). Looking at the list it jumps from Customer index 0 ( QueryResponse.Customer[0]. )  to Customer index 6 (QueryResponse.Customer[6].). The script did not skip the arrays in-between but instead found no unique values that were not already reported in the list above.

The two major ways I feel this tool can be handy are:
  1. Quickly running through a block of JSON and identifying all the unique elements that it contains so you can determine which values you want to extract from the JSON.
  2. Once the full list is generated, it is stored in a global variable and in a field as well. You can go back to this list and copy and paste the path into a JSONGetElement and it will return the result. In the demo file once you paste and parse the JSON there is a button that will open a card window and grab a random value from the generated list of keys and provide the value associated with that key.

I hope this helps simplify some of the JSON and API work people are doing. Feel free to ask any questions or provide feedback.

If you are looking to add JSON to any of your FileMaker Apps or Solutions contact the Scarpetta Group.

 

I hope this helps simplify some of the JSON and API work people are doing. Feel free to ask any questions or provide feedback. You can also contact me for a FREE demo file.

Brian Ouimette Developer - Scarpetta Group

Comments are closed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Privacy & Cookies Policy