This version is out of date, covering development from v9.0.0 to v9.3.0. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox v9 Icon

JSON processing

Tinderbox can process JSON stored in any attribute, including $Text.

Stream.json[key]

If there is no current JSON object, attempts to parse the string as JSON and fails if unsuccessful. If there is a current JSON object, that object will be reused. If the top-level element is an object, Stream.json[key] returns a dictionary for that object.

Stream.json[N]

If there is no current JSON object, attempts to parse the string as JSON and fails if unsuccessful. If there is a current JSON object, that object will be reused. If the top-level element is an array, Stream.json[N] returns the Nth object.

Stream.json.each{action}

If the top-level element is an array, rebinds the JSON object in turn to each array element. After calling the action block for each element, the JSON object is restored.

Stream.captureJSON

Attempts to parse the string as JSON and fails if unsuccessful.

JSON property chaining

JSON doesn't have a formal pathing method like Xpath in XML, but JSON properties can be chained to allow navigation to nested objects. For example, consider:


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

Thomas’s latitude can be addressed via

$Text.json["coordinates.0"] 

And his family name via

$Text.json["person.lastName"]