Tinderbox v9 Icon


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Last Altered: 

 Function  [other Function type actions]

 List  [operators of similar scope]

 Stream parsing  [other Stream parsing operators]





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.

For example, if the value of $MyString is [{"price":1}, {"price",2}], then

	$MyString.json.each{$MyList += json["price"]*3;}

would set $MyList to "3;6".


In .json.each(){…}, an optional path argument, pathStr, supplies a path to the array to be iterated. For example, if $Text is:

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

then $Text.captureJSON().json.each(coordinates){…} would iterate through the array of coordinates.

If String.json.each begins a statement,


.json.each(){} reuses the current JSON object. This can be much faster than repeatedly re-parsing a complex json package.

As a result, the older syntax $Text.json[coordinates].each(x){…}, that chained of JSON.json[keyStr] is no longer supported.

Loading a dictionary of dictionaries from JSON and looking up items

Let $Text be:

{ "French":{ "child":"enfant"; "cat":"chat"}; "Swedish":{"child":"barn";"cat":"katt"} } 


$Text.json[French][cat] is "chat"

$Text.json["Swedish"]["cat"] is "katt"

$Text.json.keys is "French; Swedish"


$MyList is [chat;katt].

Loading a list of dictionaries from JSON a and looking up items

Let $Text be:

[ { "child":"enfant"; "cat":"chat"} , {"child":"barn";"cat":"katt"} ] 


$Text.json[0][cat] is chat

$Text.json[0]['cat'] is katt

$Text.json.count is 2

	$MyList += x[child];

$MyList is now [enfant;barn].