JSON and REBOL
AltJSON (compatible with R3)
Comprehensive functions for exchanging data from REBOL to JSON serial formats. To get started, enter the following into the REBOL Console or paste into a REBOL script:
do http://reb4.me/r/altjson.r
At the Console, both functions include basic usage information:
? load-json
? to-json
to-json
This function will serialise REBOL values to a JSON string. ‘to-json is fairly agressive at converting unsupported datatypes to strings:
>> to-json ["A" "block" of 6.0 REBOL #values]
== {["A","block","of",6.0,"REBOL","values"]}
load-json
This function will attempt to decode JSON-formatted data:
>> probe load-json {{"foo":"bar","num":10,"null":null}}
make object! [
foo: "bar"
num: 10
null: none
]
Alternate usage with the /flat refinement will allow you to parse the resultant REBOL values. Object keys are imported as tag! types:
>> probe load-json/flat {{"foo":"bar","num":1.0}}
[
<foo> "bar"
<num> 1.0
]
Posted by Chris-RG, 28 days ago