Data update

This commit is contained in:
Ingy döt Net 2025-08-11 18:05:26 -07:00
parent 4d5544505c
commit 4924dd0264
3073 changed files with 55820 additions and 4408 deletions

View 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

View file

@ -0,0 +1 @@
from 'colors.json';

View file

@ -0,0 +1 @@
select json::JSON from read_csv('colors.json', header=false, sep='\t') t(json);

View file

@ -0,0 +1 @@
COPY t to 'output.json';

View file

@ -0,0 +1,30 @@
do -- JSON encode/decode - translation of the Phix sample, using Pluto's standard json module
local json = require( "json" )
print( "roundtrip (10 examples):" )
local json_strings <const> = { '{"this":"that","age":{"this":"that","age":29}}'
, '1'
, '"hello"'
, 'null'
, '[12]'
, '[null,12]'
, '[]'
, '{"this":"that","age":29}'
, '{}'
, '[null,[null,12]]'
}
for i = 1, #json_strings do
local s <const> = json_strings[ i ]
local j <const> = json.decode( s, json.withnull | json.withorder ) -- parse the string into a table
-- preserving nulls and element order
local r <const> = json.encode( j ) -- turn j back into a JSON string
local v <const> = dumpvar( j ):gsub( "\n", "" ):gsub( "\t", "" ) -- the table as a readable string
local sp <const> = " "
io.write( " ", s, if #s >= #sp then "\n "..sp else sp:sub( 1, #sp - #s ) end )
io.write( "-> ", if #v > 50 then v:sub( 1, 47 ).."..." else v end, "\n" )
io.write( if s == r then "-> " else "** " end, r, "\n\n" )
end
end

View file

@ -10,5 +10,5 @@ json-str: {{"menu": {
}
}}
res: json-to-rebol json-str
js: rebol-to-json res
reb: json-to-rebol json-str
str: rebol-to-json reb

View file

@ -0,0 +1,16 @@
json-str: {{"menu": {
"id": "file",
"string": "File:",
"number": -3,
"boolean": true,
"boolean2": false,
"null": null,
"array": [1, 0.13, null, true, false, "\t\r\n"],
"empty-string": ""
}
}}
import json ;; just in case it's not yet imported
probe reb: decode 'json json-str
probe str: encode 'json reb ;; outputs without any indentation
;; Validate that re-encoded JSON is same
probe equal? reb decode 'json str