RoryJMcEwan wrote:Hi,
I want to use a JSON link in a program. It's basically a currency converter and the rate comes from a JSON link. How can I get it so that when the figures change in the JSON a variable in live code updates? I've seen some other posts from other users about the JSON topic but I don't understand them or they're to what I'm looking for.
Could you give us more details about this "JSON link" ?
JSON is just a format for data, like XML.
Look at some example here :
http://json.org/example
So basically, if I understand what you want to achieve :
-you send a query to a webservice
-the webservice answers with data in JSON format
-LiveCode decodes the JSON format and displays an exchange rate for example
-plus you want LiveCode to automatically send the query, let's say every hour ?
--> to send the query, get the address of the webservice and the format of the data it is waiting for.
Usually, it's a POST query.
Like :
Code: Select all
put "rate=EURUSD" into tData
POST tData to url "http://www.rate.com/webservice/exchangerate"
put it into tResult
--> then after usually we need to transform the received JSON data into an array.
For this task you can use the very good library EasyJSON, here :
https://github.com/luxlogica/easyjson
With a simple command :
Code: Select all
put arrayFromJson(tResult) into tArray
Then you can explore the content of your array, and its keys.
Last but not least : if the data you receive are very simple, and if you dont want to bother with JSON library and arrays, you could perhaps parse directly the text received (thanks to the text crunching capabilities of Livecode).