Jump to content

JSON Parsing


This topic is 2389 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

Hi Guys

Thank you to Richard Carlton for his video on integrating Zippapotamus with Filemaker and the zipcode lookup. In Australia you can have multiple cities for a zipcode and the parsing code is pulling out the first entry and I would like to populated a value list if more than 1 is returned?

A scriptParameter is sending this: "place name"  &¶& $JSONdata

to:

Let (     ~startPosition = Position ( $JSONdata ; Quote ( $valueName ) ; 1 ; 1 ) + Length ( $valueName ) + 1 ;     Middle ( $JSONdata ; ~startPosition ; Position ( $JSONdata ; "\"" ; ~startPosition ; 1 ) - ~startPosition ) )

Here is the JSON data

{"post code": "4220", "country": "Australia", "country abbreviation": "AU", "places": [{"place name": "Burleigh Heads", "longitude": "153.45", "state": "Queensland", "state abbreviation": "QLD", "latitude": "-28.1"}, {"place name": "Burleigh Waters", "longitude": "153.4341", "state": "Queensland", "state abbreviation": "QLD", "latitude": "-28.0895"}, {"place name": "Burleigh Town", "longitude": "153.4341", "state": "Queensland", "state abbreviation": "QLD", "latitude": "-28.0895"}, {"place name": "Miami", "longitude": "153.4341", "state": "Queensland", "state abbreviation": "QLD", "latitude": "-28.0895"}]}

Only the first "Place name" is being returned. Thank you in advance. Ron

Link to comment
Share on other sites

  • Newbies

The answer is firstly get a count of the items

ValueCount (   JSONListKeys ( Clients::JSONZIPDATA; "places" ) )

then loop through and create the list

set variable[$i ; Value: 0 ]

Loop

Set variable[ $list & "¶" & JSONGetElement ( Clients::JSONZIPDATA ; "places[" & $i & "].place name") ]

end loop

 

Link to comment
Share on other sites

This topic is 2389 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.