JSON (JavaScript Object Notation), is a format that uses text to transmit data as attribute value pairs, and is usually used between web servers and web applications. JSON is used as an alternative to XML. E.g JSON is used when interacting with a variety of API’s such as Mandrill

The following is an example of JSON data representation:

 "firstName": "Simon",
 "lastName": "Smith",
 "contact": {
 "website": "www.activethought.net",
 "city": "Cape Town"
 "phoneNumbers": [
 "type": "mobile",
 "number": "0833067862"

Using JSON with LiveCode Server

LiveCode does not have any built-in ways to interact with JSON data, but luckily there are a couple of 3rd party scripts you can use (or you could write your own). The common way of interacting with JSON is via arrays, incoming JSON data is converted to array’s and converting an array to JSON when sending.

For this example I am using EasyJSON

Parsing incoming JSON data.

Convert JSON to an array

include "easyjson.lc"
put URL "http://mydomain.com/json.json" into pJson -- incoming JSON
put arrayFromJSON( pJson ) into jsonArray -- converts the JSON data to a multi-dimensial array

Convert an array to JSON

include "easyjson.lc"
put URL "http://shream.net/guide/json.json"into pJson -- contains the JSON content above
put arrayFromJSON( pJson ) into jsonArray


Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt

Start typing and press Enter to search