AnsweredAssumed Answered

Parse JSON - Multiple Returns for 1 Records

Question asked by AnthonyTesoriero on Dec 20, 2018
Latest reply on Dec 24, 2018 by steve_ssh

Hello All,

 

I am hoping for some help and collaboration as I try to learn how to more aptly use Filemaker to retrieve and parse JSON. Attached is an experimental file I created to start that calls upon an Open Data source for businesses licensed in NY to repair automobiles. A token is not required to search. I have been slowly building this as I learn. The utility currently calls to the data source and searches for businesses by license number. Credit to toddgeist for the "Generator" utility which I used to help me extract the fields. Credit to Goya_Pty User16087 for their Stripe CC utility which served as the original template which is now heavily modified as I experimented and learned. Credit to MarkMunro[WriteTrackMedia] author of Learn Filemaker as his freeware custom functions and utilities for helping me better understand the proper way to get the path.

 

As is pertains specifically to this file, the utility is successful in retrieving a record for a successful license search but that is about it. I have successfully figured out how to read raw JSON into the fields when searching by license number. It is pretty straightforward and I do understand this part of the process now.

 

Where I am currently stumped is when there are multiple records retrieved.  If you look at license number 7115683, which you can search in the drop down, there are 4 records that pertain to that license number. I have figured out that each record is mostly the same except for the dates of renewal. I have seen the "loop" scripting in multiple examples but cannot for the life of me get it to work correctly for me nor can I seem to yet grasp how to effectively use it.

 

So the first question is how do I write the JSON to return all iterations of the record and give the user the opportunity to select which record they want/and or if all the info is mostly the same ie, name, address etc but the only data that differs in the licensing dates, how could I capture that across multiple records from the array and bring it into my Filemaker fields in a meaningful way, ie Date of first license: XXXX, renewed: XXXX Last Expiration Date: XXXX

 

The second question would be how do I structure JSON requests to search “near matches” in other words, If I know of, and search for a specific license number, in this case, it is relatively straightforward since the licenses are all 7 digits, no spaces. But if I wanted to search by business name for instance and I misspelled the name of the shop by a letter or left off an “.” In the inc abbreviation etc how would I get the JSON to return the data I’m looking for or a list of near data returns from which the user could choose the most pertinent match?

 

Thank you again for your willingness to assist.

 

ORIGINAL ATTACHMENT DELETED/ UPDATED ATTACHMENT BELOW IN COMMENTS

Outcomes