diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-10-11 20:47:27 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-10-11 20:47:27 -0700 |
commit | aa02bc7f31edabb9e09f9756d7ae8fbc41995017 (patch) | |
tree | 60bd97475501b9c8484f3804a5ac5d409113d373 /stream.c | |
parent | 5df51b54116d4287df161c42ca0edb16fb1f79a5 (diff) | |
download | txr-aa02bc7f31edabb9e09f9756d7ae8fbc41995017.tar.gz txr-aa02bc7f31edabb9e09f9756d7ae8fbc41995017.tar.bz2 txr-aa02bc7f31edabb9e09f9756d7ae8fbc41995017.zip |
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.
Diffstat (limited to 'stream.c')
-rw-r--r-- | stream.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -95,9 +95,11 @@ val get_error_s, get_error_str_s, clear_error_s, get_fd_s; val print_flo_precision_s, print_flo_digits_s, print_flo_format_s; val pprint_flo_format_s, print_base_s, print_circle_s; +val print_json_format_s; val from_start_k, from_current_k, from_end_k; val real_time_k, name_k, addr_k, fd_k, byte_oriented_k; +val standard_k; val format_s; val stdio_stream_s; @@ -5414,6 +5416,7 @@ void stream_init(void) addr_k = intern(lit("addr"), keyword_package); fd_k = intern(lit("fd"), keyword_package); byte_oriented_k = intern(lit("byte-oriented"), keyword_package); + standard_k = intern(lit("standard"), keyword_package); format_s = intern(lit("format"), user_package); stdio_stream_s = intern(lit("stdio-stream"), user_package); #if HAVE_SOCKETS @@ -5469,6 +5472,7 @@ void stream_init(void) reg_var(print_base_s = intern(lit("*print-base*"), user_package), num_fast(10)); reg_var(print_circle_s = intern(lit("*print-circle*"), user_package), nil); + reg_var(print_json_format_s = intern(lit("*print-json-format*"), user_package), nil); #if HAVE_ISATTY if (isatty(fileno(stdin)) == 1) { |