Infotable to Json gives datashape information
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Coding
-
Design
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Yep for sure you will have to do three inner loops.
