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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

How to convert a "Json input" to an "Infotable" in a ThingWorx service

100% helpful (1/1)

1. Add an Json parameter

  • Example:

​    "rows":[

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++) {



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.


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.

Found a dynamic way of addning my JSON data to an infotable that might help someone else.

 * Input: jsonInput (JSON) 
let result = Resources["InfoTableFunctions"].CreateInfoTable();
for(let i=0; i<jsonInput.value.length; i++){
  //Get object
  let json = jsonInput.value[i];
  //Adding fields for all attributes
  let keys = Object.keys(json);
  for (let i = 0; i < keys.length; i++) {
   result.AddField({ name: keys[i], baseType: 'STRING' });

  //Example of manipulated values
  json.Mashup = "MashupObject" + json.ObjectType.replace(" ", "");
  json.Url = baseUrl + "/app/#ptc1/tcomp/infoPage?oid=" + 
  json.ID.replace(/:/g, '%3A');

  //Adding object

 Keywords: ThingWorx JSON to Infotable. 

Version history
Last update:
‎Mar 27, 2017 02:13 AM
Updated by:
Labels (2)