Finch/tests/new/std_json.out
Nexoniarz ea6d2a57e5 a standard library in Finch: path, time, proc, json
import json   import path   import time   import proc  -- found in std/ after the program's own files,
so a program's own json.fch always wins.

path: join, base, dir, ext, stem, parts, clean, is_abs.
time: now, millis, sleep, date, local, format, days_in_month (clock_gettime, strftime through C import).
proc: run, output (an error with the command's output when it fails), env, pid, cwd.
json: parse (errors with line and column), stringify, pretty, new_*, get/at/set/push/has/names and
str_or/int_or/float_or/bool_or; \u escapes with surrogate pairs.

The C importer now leaves a plain (non-const) char * parameter a ptr[char], a buffer C writes into;
only const char * is text going in. str(ptr) and str([]u8) are in the self-hosted compiler.

boot.sh: 40 passed, 0 failed.
2026-10-25 20:58:26 +01:00

26 lines
882 B
Text

Finch small 5 3.25
true true true true false
2 2 ["name", "tags", "stars", "pi", "ok", "none", "nested"]
{"name":"Finch","tags":["fast","small"],"stars":5,"pi":3.25,"ok":true,"none":null,"nested":{"deep":[1,[2,3]]}}
{"greeting":"replaced","values":[1,2.5,false,null],"empty":{}}
{
"greeting": "replaced",
"values": [
1,
2.5,
false,
null
],
"empty": {}
}
true
café 😀 /
0 -125
json: found '}' where a value should be (line 1, column 7)
json: the text ends where ',' or ']' should be (line 1, column 6)
json: found '1' where ':' should be (line 1, column 6)
json: found 't' where 'true' should be (line 1, column 1)
json: found 'x' where the end of the text should be (line 1, column 5)
json: a text is never closed (line 1, column 6)
json: the text ends where a value should be (line 1, column 1)
json: found 'o' where a value should be (line 2, column 3)