summaryrefslogtreecommitdiffstats
path: root/stream.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-07-12 01:32:47 -0700
committerKaz Kylheku <kaz@kylheku.com>2024-07-12 01:32:47 -0700
commit7dbdc52b4351a44b5d5e18a2fa73ec2f2c16d4c2 (patch)
tree6452046e87f6e1962857ba353849970fe7820208 /stream.c
parentb2bb2af765a550efd92adb25687cb76f955574e3 (diff)
downloadtxr-7dbdc52b4351a44b5d5e18a2fa73ec2f2c16d4c2.tar.gz
txr-7dbdc52b4351a44b5d5e18a2fa73ec2f2c16d4c2.tar.bz2
txr-7dbdc52b4351a44b5d5e18a2fa73ec2f2c16d4c2.zip
json: new special var *print-json-type*.
This variable controls whether we emit the "__type" key for structures. * lib.c (out_json_rec): React to the new variable, via the flag in the json_opts structure: include the "__type" key only if it is requested. (out_json, put_json): Initialize the type flag in the josn_opts according to the *print-json-type* dynamic variable. * stream.c (print_json_type_s): New symbol variable. (stream_init): print_json_type_s initialized, and corresponding special variable registered, with intial value t. * stream.h (struct json_opts): New bitfield member, type. (print_json_type_s): Declared. * txr.1: Documented.
Diffstat (limited to 'stream.c')
-rw-r--r--stream.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/stream.c b/stream.c
index 7114a123..58d0804f 100644
--- a/stream.c
+++ b/stream.c
@@ -95,7 +95,7 @@ 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 print_json_format_s, print_json_type_s;
val from_start_k, from_current_k, from_end_k;
val real_time_k, name_k, addr_k, fd_k, byte_oriented_k;
@@ -5587,6 +5587,7 @@ void stream_init(void)
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);
+ reg_var(print_json_type_s = intern(lit("*print-json-type*"), user_package), t);
#if HAVE_ISATTY
if (isatty(fileno(stdin)) == 1) {