Using JSON
JSON is a string representation of a JavaScript object that can be transmitted over the network. You can use it to pass parameters inside IBM® BPM.
About this task
Procedure
Add this file to your toolkit or process application as
a server managed file to provide new global methods and objects.
Example
var newArray = new Array();
for (var j=0; j<tw.local.myPurchase.listLength; j++)
{
var newObj = new Object();
for (var property in tw.local.myPurchase[j].propertyNames)
{
var name = tw.local.myPurchase[j].propertyNames[property];
newObj[name] = tw.local.myPurchase[j][name];
}
newArray.push(newObj);
}
var jsonText = JSON.stringify(newArray);
log.error("jsonText = " + jsonText);
Within a browser
or the coach, you can use the Dojo classes to work with JSON:
- dojo.fromJson(string) parses a JSON string to return a JavaScript object.
- dojo.toJson(Object) returns a JSON string given a JavaScript object.
