Tinderbox v10 Icon

JSON.jsonValue()


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]

 source context dependent

 v9.6.0

 Baseline

 As at baseline


Syntax note: Operators without any defined mandatory arguments may omit their empty closing parentheses


JSON.jsonValue()

JSON.jsonValue

The .jsonValue() operator returns a json object, from the cursor position to the end of the current code. In an attribute, e.g. $Text, containing only JSON code, the operator returns that whole code segment. If, via stream parsing the input cursor has advanced to the start of a code segment, the complete code segment starting at that point is returned (though other discrete code samples may exist further on the source string—these are ignored)

For example, if $Text is :

Some text.
{
  "person": { "firstName": "Thomas", "lastName": "Roe" }, 
  "coordinates": [-90,41]
}

Then:

$MyString = $Text.skipline.captureJson.jsonValue(); 

sets $MyString to the JSON code found in $Text starting at the second paragraph. Note: the captured JSON is the first discrete section of code in text. This if $Text (or other source string) is all JSON code, the use of .captureJson() is moot But, if the $Text (or other source string) contains more than one JSON code section, use stream parsing to detect the desired JSON section and .jsonValue()to capture the desired section of code.


See also—notes linking to here: