From 8cee66e60929f274555f57154b82d8f48a417d50 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Fri, 29 Nov 2013 16:26:52 -0600 Subject: [PATCH] Document tojson and fromjson builtins --- docs/content/3.manual/manual.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/content/3.manual/manual.yml b/docs/content/3.manual/manual.yml index 876704c..12920e1 100644 --- a/docs/content/3.manual/manual.yml +++ b/docs/content/3.manual/manual.yml @@ -915,6 +915,24 @@ sections: input: '42' output: ['"The input was 42, which is one less than 43"'] + - title: "Convert to/from JSON" + + The `tojson` and `fromjson` builtins dump values as JSON texts + or parse JSON texts into values, respectively. The tojson + builtin differs from tostring in that tostring returns strings + unmodified, while tojson encodes strings as JSON strings. + + examples: + - program: '[.[]|tostring]' + input: '[1, "foo", ["foo"]]' + output: '["1","foo","[\"foo\"]"]' + - program: '[.[]|tojson]' + input: '[1, "foo", ["foo"]]' + output: '["1","\"foo\"","[\"foo\"]"]' + - program: '[.[]|tojson|fromjson]' + input: '[1, "foo", ["foo"]]' + output: '[1,"foo",["foo"]]' + - title: "Format strings and escaping" body: | -- 2.49.0