1. Add an Json parameter
{
"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)
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});
}
In the snippets collections there is a set of functions under "InfoTableFunctions".
According to the tooltip, the "FromJSON" function should create an infotable out of a JSON input.
Did anyone get that to work?
Hi Erik,
To use it, JSON input should be on TW specific Infotable JSON format. If you don't have the JSON on TW Infotable JSON format, better you go parsing the JSON, and adding it's contents to the InfoTable through AddRow method.
Carles.
Thanks for the quick reply, this worked fine!
It would be nice with ready made snippets to automatically create a data shape and infotable when interacting with external REST APIs.
Check out the upcoming Expert Session: Understanding ThingWorx Navigate Licensing in Community "Customer Events" section.