cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Infotable to Json gives datashape information

sbt
13-Aquamarine
13-Aquamarine

Infotable to Json gives datashape information

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

ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

3 REPLIES 3

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.

sbt
13-Aquamarine
13-Aquamarine
(To:CarlesColl)

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.

Announcements

Top Tags