For JMP 14, I've been exercising the new HTTP Request object found in JSL. I came across this API, founds here: http://api.citybik.es/v2/.
This web service can be used to locate City Bike data (and availablilty) world wide. It has only two endpoints http://api.citybik.es/v2/networks and http://api.citybik.es/v2/networks/[id] so it is a pretty simple Rest API to work with. The key, though, is how to configure the HTPP Request object to send to the website and then how to process that information. (Processing the information can be as involved as you want to be)
This is all that is required to get data from the first endpoint. json is the data that is getting returned from the API. Since I know this web service, I know the data I should be getting back is Character and it is JSON I'll just check:
However, you can check for success and mimetype returned like:
request << Is Successful
request << Get Mime Type == "application/json"
The intial JMP Data Table created from the script is the City Bikes Network table.
It's create from the json data that is returned from the first endpoint. There are [at least] two ways you can process the returned data. The first is:
JSON to Data Table(json)
This will try to create a JMP Data Table from the data. For "rectangular" or "tabluar" data this works really well (and fast). However, not all webservices return tabular data (City Bikes is one that does not). This brings us to the second way of processing returned data:
This creates a JSL Associative Array. This means you don't have to parse the JSON yourself in JSL, but you do, however need to know how the data is structured. That is you'll need to know if it's a key=>value pair or a key=>values pair. This isn't as hard as it seems since you can capture the raw json output like:
in the log and paste it into your favorite json formatter. (I use JSON Editor Online app in Chrome). This means something like this: