From aa02bc7f31edabb9e09f9756d7ae8fbc41995017 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 11 Oct 2022 20:47:27 -0700 Subject: json: support standard-style formatting. * stream.c (standard_k, print_json_format_s): New symbol variables. (stream_init): New variables initialized. * stream.h (enum json_fmt): New enum. (standard_k, print_json_format_s): Declared. * lib.c (out_json_rec): Take enum json_fmt param, and pass it recursively. Printing for vector and dictionaries reacts to argument value. (out_json, put_json): Examine value of special var *print-json-format* and calculate enum json_fmt value from this. Pass to out_json_rec. * txr.1: Documented. * stdlib/doc-syms.tl: Updated. --- txr.1 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index be539219..846c35d4 100644 --- a/txr.1 +++ b/txr.1 @@ -79981,6 +79981,29 @@ argument is passed to that function, defaulting to The value returned is that of .codn put-jsons . +.coNP Variable @ *print-json-format* +.desc +The +.code *print-json-format* +variable controls the formatting style exhibited by +.code put-json +and related functions. The initial value of this variable is +.codn nil . + +If the value is the keyword symbol +.codn :standard , +then a widely-used format is used, in which the opening and closing +braces and brackets of vectors and dictionaries are printed +on separate lines, as are the elements of those objects. + +If the variable +has any other value, including the initial value +.codn nil , +then a default format is used in which braces, brackets +and elements appear on the same line, subject to automatic +breaking and indentation, similar to the way Lisp nested +list structure is printed. + .coNP Variable @ *read-bad-json* .desc This dynamic variable, initialized to a value of -- cgit v1.2.3