How to convert a "Json input" to an "Infotable" in a ThingWorx service
1. Add an Json parameter
- Example:
{
"rows":[
{
"email":"example1@ptc.com"
},
{
"name":"Qaqa",
"email":"example2@ptc.com"
}
]
}
2. Create an Infotable with a DataShape usingCreateInfoTableFromDataShape(params)
3. Using a for loop, iterate through each Json object and add it to the Infotable usingInfoTableName.AddRow(YourRowObjectHere)
- Example:
var params = {
infoTableName: "InfoTable",
dataShapeName : "jsontest"
};
var infotabletest = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
for(var i=0; i<json.rows.length; i++) {
infotabletest.AddRow({name:json.rows.name,email:json.rows.email});
}

