Some web sites provide a REST API to read data, and often the response is text in JSON format. How do we get that into JMP?
Here is a example using the meetup.com REST API. It's relatively simple since it uses the common "GET" method, which is the default for web page reading. More elaborate messages use the "POST" method which would require a different approach. With the GET request, the inputs are appended to the URL itself.
my key = load text file("meetupkey.txt"); // I stored my key in a text file event id = "246678392"; // the meetup id at the end of the event's URL
url = "https://api.meetup.com/2/rsvps?key=" || my key || "&event_id=" || event id;
s = load text file( url ); // s contains the JSON result as a big string
// We could store that in a file and then open the file, but here's a shortcut. // The Open() function can read data directly from a blob -- you just have to tell it the file type
b = char to blob(s);
dt = open(b, "JSON"); // JMP interprets the JSON structured tree into a flat data table, with surprisingly good results.
After reading the data, I often do some clean-up and create convenience columns, such as:
dt << New Column("reply time", formula(:results.mtime/1000 + 01Jan1970), format("ddmonyyyy"));
dt << New Column("count", formula(if(:results.response=="yes", :results.guests + 1, 0)));
Having this in a scripts makes it easy to refresh my data as needed. Now I'm ready to do some exploration..