From 60dd1c1c6af5c179f598dea60896ba9584d139ad Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 3 Sep 2023 20:34:22 -0700 Subject: json: allow integers and lists. * lib.c (out_json_rec): Handle NUM and BGNUM cases same as FLNUM so integers get printed. The restriction against integers has been largely unhelpful and bothersome. Handle LCONS together with CONS. Lists that are not special notation fall through to the VEC case, which now uses seq_iter_t iteration to handle vectors and lists. * tests/010/json.tl: New tests. * txr.1: Documented support for printing integers and lists. --- tests/010/json.tl | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/010/json.tl') diff --git a/tests/010/json.tl b/tests/010/json.tl index dfd45173..f613c93a 100644 --- a/tests/010/json.tl +++ b/tests/010/json.tl @@ -184,3 +184,8 @@ (command-put-jsons `cat > @name` '(#() 1.0 nil)) t (file-get-string name) "[]\n1\nfalse\n" (command-get-jsons `cat @name`) (#() 1.0 nil)))) + +(mtest + (tojson 1) "1" + (tojson 123123123123123123123123123123) "123123123123123123123123123123" + (tojson '(1 2 3 4 5)) "[1,2,3,4,5]") -- cgit v1.2.3