RosettaCodeData/Task/JSON/Phix/json.phix

26 lines
794 B
Plaintext

--
-- demo\rosetta\JSON.exw
-- =====================
--
include builtins/json.e
puts(1,"roundtrip (10 examples):\n")
sequence json_strings = {"{\"this\":\"that\",\"age\":{\"this\":\"that\",\"age\":29}}",
"1",
"\"hello\"",
"null",
"[12]",
"[null,12]",
"[]",
"{\"this\":\"that\",\"age\":29}",
"{}",
"[null,[null,12]]"}
for i=1 to length(json_strings) do
string s = json_strings[i]
puts(1,s&"\n")
object json_object = parse_json(s)
puts(1,print_json("",json_object,true)&"\n")
if not equal(print_json("",json_object,true),s) then ?9/0 end if
end for