diff options
-rw-r--r-- | lib.c | 24 | ||||
-rw-r--r-- | txr.1 | 24 |
2 files changed, 12 insertions, 36 deletions
@@ -12644,7 +12644,7 @@ static void out_json_rec(val obj, val out, struct strm_ctx *ctx) } break; case CONS: - { + if (ctx != 0) { val sym = car(obj); if (sym == hash_lit_s) { val save_indent; @@ -13461,23 +13461,11 @@ val tostringp(val obj) val tojson(val obj, val flat) { - if (consp(obj) && eq(car(obj), json_s)) { - val ss = make_string_output_stream(); - if (default_null_arg(flat)) - set_indent_mode(ss, num_fast(indent_foff)); - obj_print(obj, ss, nil); - return get_string_from_stream(ss); - } else { - val json = cons(json_s, cons(quote_s, cons(obj, nil))); - val ss = make_string_output_stream(); - if (default_null_arg(flat)) - set_indent_mode(ss, num_fast(indent_foff)); - obj_print(json, ss, nil); - rcyc_pop(&json); - rcyc_pop(&json); - rcyc_pop(&json); - return get_string_from_stream(ss); - } + val ss = make_string_output_stream(); + if (default_null_arg(flat)) + set_indent_mode(ss, num_fast(indent_foff)); + out_json_rec(obj, ss, 0); + return get_string_from_stream(ss); } val display_width(val obj) @@ -71854,18 +71854,6 @@ function converts .meta obj into JSON notation, returned as a character string. -If -.meta obj -is -.code json -macro syntax generated by the parser, or else generated programmatically in a compatible way, -then this is converted back into JSON syntax. - -Otherwise if -.meta obj -conforms to the conventions by which JSON objects are represented in Lisp, -it is converted to JSON syntax also. - The behavior is unspecified if .meta obj or any component of @@ -71873,10 +71861,10 @@ or any component of is an object incompatible with the JSON representation conventions. An exception may be thrown. -An object conforms to the JSON representation conventions if: +An object conforms to the JSON representation conventions if it is: .RS .IP 1. -It is one of the symbols +one of the symbols .codn nil , .code t or @@ -71888,13 +71876,13 @@ and .codn null , respectively. .IP 2. -It is a floating-point number. +a floating-point number. .IP 3. -It is a character string. +a character string. .IP 4. -It is a vector of JSON-conforming objects. +a vector of JSON-conforming objects. .IP 5. -It is a hash table whose keys and values are JSON-conforming objects. +a hash table whose keys and values are JSON-conforming objects. .RE .IP Note that if unless the keys in a hash table are all strings, nonstandard JSON |