This page describes features, codes or syntax whose use is now DEPRECATED, i.e. not advised either for new or continued pre-existing use.
Deprecated aspects of Tinderbox may be supported on a legacy basis but the latter support can not be presumed to be indefinite. Therefore you should update your active TBX documents to latest practice as soon as practical.
Operator Type:
Operator Scope of Action:
Operator Purpose:
Data Type Returned:
Operator First Added:
Operator in Current Baseline:
Operator Last Altered:
Function [other Function type actions]
Item [operators of similar scope]
Stream parsing [other Stream parsing operators]
String [about String data type]
v9.1.0
Baseline
11.5.0
Syntax note: Operators without any defined mandatory arguments may omit their empty closing parentheses
String.captureJson()
String.captureJson
From v11.5.0, the .captureJson() operator is deprecated. That proved to be a wrong step; embedding json in $Text (or within other text) is not useful and better solutions are available.
Attempts to parse the string as fully/partially JSON and fails if unsuccessful. The parsed JSON is saved as the current JSON (stream) object.
Essentially, this re-scopes the current stream so that it contains only the contents of the first section of JSON detected within the original stream. The focus of the stream parsing is set to the beginning of the extracted JSON code.
Only one JSON object may be current at any time. If the source stream contains multiple discrete JSON code sections, only the first is detected/used.
To actually work with the JSON data's values, use JSON.json[] and its sibling operators.
In the most likely scenario, working on $Text, .captureJson() is needed only if $Text contains both JSON and other text:
$MyResult = $Text.captureJson().json["somekey"];
But, if the whole of $Text is a single block of (complete) JSON, use .json[] directly. So:
$MyResult = $Text.json["somekey"];
Legacy usage
Prior to v10.0.2, the operator used the casing .captureJSON(). This version is still silently supported (and is coloured in supported input boxes). However, .captureJson() is not the approved casing and existing code should be updated to this as legacy support may stop at any time.
See also—notes linking to here: