From 386ab6457bb9dd4901391ffe7ceb5fbe08705c09 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 22 Jan 2019 20:57:58 +0000 Subject: JSON: add jsons extract variant, to strip quotes from string results --- doc/doc-docbook/spec.xfpt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt index d21a71857..d762f9754 100644 --- a/doc/doc-docbook/spec.xfpt +++ b/doc/doc-docbook/spec.xfpt @@ -9412,6 +9412,8 @@ This forces an expansion failure (see section &<>&); .new .vitem "&*${extract json{*&<&'key'&>&*}{*&<&'string1'&>&*}{*&<&'string2'&>&*}&&& {*&<&'string3'&>&*}}*&" +.vitem "&*${extract jsons{*&<&'key'&>&*}{*&<&'string1'&>&*}{*&<&'string2'&>&*}&&& + {*&<&'string3'&>&*}}*&" .cindex "expansion" "extracting from JSON object" .cindex JSON expansions The key and <&'string1'&> are first expanded separately. Leading and trailing @@ -9425,8 +9427,11 @@ The expanded <&'string1'&> must be of the form: The braces, commas and colons, and the quoting of the member name are required; the spaces are optional. Matching of the key against the member names is done case-sensitively. -If a returned value is a JSON string, it retains its leading and +For the &"json"& variant, +if a returned value is a JSON string, it retains its leading and trailing quotes. +For the &"jsons"& variant, which is intended for use with JSON strings, the +leading and trailing quotes are removed. . XXX should be a UTF-8 compare The results of matching are handled as above. @@ -9467,6 +9472,8 @@ empty (for example, the fifth field above). .new .vitem "&*${extract json{*&<&'number'&>&*}}&&& {*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&" +.vitem "&*${extract jsons{*&<&'number'&>&*}}&&& + {*&<&'string1'&>&*}{*&<&'string2'&>&*}{*&<&'string3'&>&*}}*&" .cindex "expansion" "extracting from JSON array" .cindex JSON expansions The <&'number'&> argument must consist entirely of decimal digits, @@ -9474,8 +9481,11 @@ apart from leading and trailing white space, which is ignored. Field selection and result handling is as above; there is no choice of field separator. -If a returned value is a JSON string, it retains its leading and +For the &"json"& variant, +if a returned value is a JSON string, it retains its leading and trailing quotes. +For the &"jsons"& variant, which is intended for use with JSON strings, the +leading and trailing quotes are removed. .wen -- cgit v1.2.3