summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
Diffstat (limited to 'txr.1')
-rw-r--r--txr.166
1 files changed, 66 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index 94a88cc1..dffd9b4b 100644
--- a/txr.1
+++ b/txr.1
@@ -71808,6 +71808,72 @@ etc.
.SS* Data Interchange Support
+.coNP Function @ tojson
+.synb
+.mets (tojson < obj <> [ flat-p ])
+.syne
+.desc
+The
+.code tojson
+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
+.meta obj
+is an object incompatible with the JSON representation conventions.
+An exception may be thrown.
+
+An object conforms to the JSON representation conventions if:
+.RS
+.IP 1.
+It is one of the symbols
+.codn nil ,
+.code t
+or
+.codn null ,
+which map to the JSON keywords
+.codn false ,
+.code true
+and
+.codn null ,
+respectively.
+.IP 2.
+It is a floating-point number.
+.IP 3.
+It is a character string.
+.IP 4.
+It is a vector of JSON-conforming objects.
+.IP 5.
+It is 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
+is produced, since RFC 8259 requires JSON object keys to be strings.
+
+If the
+.code flat-p
+argument is present and has a true value, then the JSON is generated
+without any line breaks or indentation.
+
+Otherwise, the JSON is potentially subject to such formatting.
+
+Even if the JSON data contains line breaks, it does not end in a line break.
+
.coNP Macro @ json
.synb
.mets (json [quote | sys:qquote] << object )