Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
28
Task/JSON/Agena/json.agena
Normal file
28
Task/JSON/Agena/json.agena
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
scope # JSON encode/decode - translation of the Phix sample, using Agena's standard json module
|
||||
|
||||
import json;
|
||||
|
||||
print( "roundtrip (10 examples):" );
|
||||
|
||||
local constant json_strings := [ '{"this":"that","age":{"this":"that","age":29}}'
|
||||
, '1'
|
||||
, '"hello"'
|
||||
, 'null'
|
||||
, '[12]'
|
||||
, '[null,12]'
|
||||
, '[]'
|
||||
, '{"this":"that","age":29}'
|
||||
, '{}'
|
||||
, '[null,[null,12]]'
|
||||
];
|
||||
|
||||
for i to size json_strings do
|
||||
local constant s := json_strings[ i ];
|
||||
local constant j := json.decode( s );
|
||||
local constant r := json.encode( j );
|
||||
local constant pad := if size s < 29 then 30 else size s + 1 fi;
|
||||
print( " " & strings.ljustify( s, pad ) & " -> "
|
||||
, j, "\n" & if s = r then "-> " else "** " fi & r & "\n"
|
||||
)
|
||||
od
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue