@@ -4,7 +4,7 @@ json - Parse, manipulate and produce JSON documents
44
55## SYNOPSIS
66
7- ** package require rl_json** ?** 0.16 ** ?
7+ ** package require rl_json** ?** 0.17 ** ?
88
99** json get** ?** -default** * defaultValue* ? * jsonValue* ?* key …* ?
1010** json extract** ?** -default** * defaultValue* ? * jsonValue* ?* key …* ?
@@ -31,7 +31,8 @@ json - Parse, manipulate and produce JSON documents
3131** json keys** * jsonValue* ?* key …* ?
3232** json decode** * bytes* ?* encoding* ?
3333** json valid** ?** -extensions** * extensionlist* ? ?** -details**
34- * detailsvar* ? * jsonValue*
34+ * detailsvar* ? * jsonValue*
35+ ** json quirk** * quirk* ?* value* ?
3536
3637## DESCRIPTION
3738
@@ -286,6 +287,43 @@ The document that failed validation
286287** char_ofs**
287288The character offset into ** doc** that caused validation to fail.
288289
290+ ** json quirk** * quirk* ?* value* ?
291+ Control or query process-scope encoding quirks used to work around
292+ mismatches between strict JSON and specific third-party consumers. If
293+ * value* is provided, set the quirk to that value. Returns the current
294+ state of the quirk. Currently supported quirks:
295+
296+ ** non-finite-doubles** (reject \| stringify \| null) — Control how
297+ non-finite floating-point values (NaN, ±Infinity) are handled when they
298+ would otherwise be installed as JSON numbers (via ** json number** ,
299+ ** ~ N:** template substitutions, or ** json set** type inference).
300+
301+ : ** reject** (default) — raise a Tcl error with errorcode ** RL JSON
302+ NUMBER NONFINITE** . The JSON grammar has no representation for
303+ non-finite numbers, so the safe stance is to refuse rather than silently
304+ emit something invalid.
305+
306+ : ** stringify** — transmute to a JSON string using the AWS SDK v2 /
307+ JSON5 spellings ** “NaN”** , ** “Infinity”** , ** “-Infinity”** (positive
308+ infinity has no leading “+”). Useful when interfacing with APIs that
309+ accept these as strings (e.g. several AWS services).
310+
311+ : ** null** — transmute to JSON ** null** , matching JavaScript’s
312+ ** JSON.stringify()** . Always produces valid JSON but silently drops the
313+ sign and magnitude of the value.
314+
315+ The quirk state only affects values resolved * after* it is set —
316+ Tcl_Objs that already carry a cached JSON intrep keep their resolution.
317+ Set the required quirk before encoding any non-finite values if you want
318+ consistent output.
319+
320+ ** json valid** is unaffected by this quirk: the bare string “NaN” /
321+ “Inf” / … is never valid JSON under any ** -extensions** setting, whether
322+ or not the quirk would later transmute it.
323+
324+ Since this command changes state for all interpreters in the process, it
325+ is not available in safe interpreters.
326+
289327## PATHS
290328
291329Several of the commands (e.g., ** json get** , ** json exists** , ** json
@@ -781,7 +819,7 @@ Build from a specified release version, minimising image size:
781819
782820``` dockerfile
783821WORKDIR /tmp/rl_json
784- RUN wget https://github.com/RubyLane/rl_json/releases/download/v0.16 /rl_json-v0.16 .tar.gz -O - | tar xz --strip-components=1 && \
822+ RUN wget https://github.com/RubyLane/rl_json/releases/download/v0.17 /rl_json-v0.17 .tar.gz -O - | tar xz --strip-components=1 && \
785823 meson setup builddir --buildtype=release && \
786824 meson install -C builddir && \
787825 strip /usr/local/lib/lib*rl_json*.so && \
0 commit comments