chelnak
8/10/2015 - 4:47 PM

A vRO Scriptable task that will parse a JSON Resource Element

A vRO Scriptable task that will parse a JSON Resource Element

//vRO Scriptable task to parse a resource element and
//edit values

//inputs:
//jsonTemplate : ResourceElement
//reservationName : String
//subtenantId : String

//outputs
//payload : String

//Get the content of the Resource Element
template = jsonTemplate.getContentAsMimeAttachment();

//Use JSON.parse to parse content in to a useable object
jsonObject = JSON.parse(template.content);

//Now we can manipulate individual values, which makes the template dynamic
jsonObject['name'] = reservationName;
jsonObject['subTenantId'] = subtenantId;

//Convert object back to string ready to POST
payload = JSON.stringify(jsonObject);