Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Hello,
I am using the below code to convert the infotable to JSON. But i see that the JSON also contains the datashape information which i dont need. How can i get ride of this datashape information in the JSON output.
var params = {
table: outPutInfo /* INFOTABLE */
};
var result = Resources["InfoTableFunctions"].ToJSON(params);
Thanks
Solved! Go to Solution.
I would do something like this:
var params = {
table: outPutInfo /* INFOTABLE */
};
var result = Resources["InfoTableFunctions"].ToJSON(params);
result.array = result.rows;
delete result.rows;
delete result.dataShape;
The reason to rename rows to array it's to conform to ThingWorx handling of JSON and infotables, if it sees a rows property it expects a dataShape otherwise it can crash or get stuck, if you convert it to a ThingWorx raw JSON array which requieres the naming convention "array" you are good to go.
Regards.
I would do something like this:
var params = {
table: outPutInfo /* INFOTABLE */
};
var result = Resources["InfoTableFunctions"].ToJSON(params);
result.array = result.rows;
delete result.rows;
delete result.dataShape;
The reason to rename rows to array it's to conform to ThingWorx handling of JSON and infotables, if it sees a rows property it expects a dataShape otherwise it can crash or get stuck, if you convert it to a ThingWorx raw JSON array which requieres the naming convention "array" you are good to go.
Regards.
Hello Carles,
Thats good information about handling Infotable and JSON in thingworx.
In my case I have infotable which contains infotable and that contains infotable, so its like 3 level and may change to more than 3. So in that case should i loop through the depth ?? or what is the efficient way to achieve the same.
Thanks you!
Yep for sure you will have to do three inner loops.