JSON

The JSON action in Lucid allows you to make simple JSON calls. A JSON call is a simple AJAX call which returns JSON data to your page, rather than XML. There are limitations to the capabilities with regard to making calls to domains other than your own, to attempt to overcome this, there is JSONP, for which Lucid supplies a few examples in the gear menu. Because these security measures are different across each browser, you should ensure you thoroughly test on the browsers which are important to you.

A simple JSON call

A simple JSONP call is supplied in the gear menu for getting the Longitude and Latitude from a U.S. Postal Code. You will see that the Variable field is set to event.jsonData, this is so that the Google Map action can simply read this data via the event object. For this, and any other JSON action, you can insert the URL into the address field of your web browser to examine the data. In this case, paste http://www.geonames.org/postalCodeLookupJSON?postalcode=10504&country=US&callback=? into your web browser. You will see some data which looks something like this:

?({"postalcodes":[{"adminName2":"Westchester","adminCode2":"119","postalcode":"10504","adminCode1":"NY","countryCode":"US","lng":-73.700942,"placeName":"Armonk","lat":41.136002,"adminName1":"New York"}]});

This shows a dictionary with one element called 'postalcodes'. The value for the element is a one element array, with that element containing data for the post code given. If you choose the 'Partner' to this JSON method from the Google Map's gear menu, you will see how this data is accessed. JSON is a little complicated at first, but once you understand arrays and dictionaries, you will find that you can use and interpret quite complicated data structures.