Friday, 14 December 2012

Json

Json is a format to send data, if you have an application that it uses json data, the following script converts rebol data to json data.
A simple block of rebol is simpler and more efficient to send and receive data, since rebol interpreter can understand many types of data directly.
Don't try to copy and paste the script in the console, there are some unicode that wouldn't be copied, do directly the script. The script is here: http://www.rebol.org/view-script.r?script=json.r
the you can type:

do %json.r

and you have the rebol-to-json function to convert rebol data in json data. Look the following examples:

>> rebol-to-json 12
== "12"
>> rebol-to-json [12 "Hello"]
== {[12, "Hello"]}
>> rebol-to-json [12 "Hello" $33]
== {[12, "Hello", "$33.00"]}
>> a: make object! [speed: 23 greeting:"Good morning"]
>> rebol-to-json a
== {{"speed": 23, "greeting": "Good morning"}}

No comments:

Post a Comment