I find it quickest to use one of the many online JSON editors (www.jsoneditoronline.org). These validate the format so we know we have a valid file.
Code: Select all
{
"builds": {
"windows2008R2_standard": {
"memorySize": 8,
"cpuCount": 2,
"etc etc etc": ....
},
"windows2008R2_large": {
"memorySize": 16,
"cpuCount": 4,
"etc etc etc": ....
}
}
}
We can use the file as is or we can add to vRO as a Resource Element. The latter means we can simply reference the file without having to use local disk access. Either way works fine.
This example uses the file as a resource element which has been added to my workflow as an attribute. To get the data we first need to parse the file at the section we want, then we can read the individual lines.
[input resource element => osSpecifications]
Code: Select all
var osSpecs = JSON.parse(osSpecifications.getContentAsMimeAttachment().content);
var osProperties = osSpecs.builds["windows2008R2_standard"];
var cpu = osProperties.cpuCount;
Happy days
