Skip to main content
1-Visitor
August 1, 2017
Question

JSON to Infotable

  • August 1, 2017
  • 2 replies
  • 7486 views

Hi,

I ma trying to turn my JSON into an infotable. The JSON is being pushed to a propety of a thing in Thingworx from a java code. I am not sure how to go about this as all the questions I have seen are creating the json in the script. I want to place the table into a grid on a mashup.

Thank you

2 replies

5-Regular Member
August 2, 2017
1-Visitor
August 9, 2017

Links are not found!!

5-Regular Member
August 11, 2017

Hi Raj, there must be something in the community that blocked the links, sorry for that. Here I will attach the KCS number here directly, please check if they are helpful.

  • Convert JSON to an InfoTable   CS179012

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS179012&posno=1&q=Convert%20JSON%20to%20an%20InfoTable&source=…

  • Convert XML to InfoTable or DataTable   CS218242

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS218242&posno=1&q=Convert%20XML%20into%20an%20InfoTable%20or%2…

5-Regular Member
August 11, 2017

You might also like to try out this extension from the Marketplace which will translate JSON objects into InfoTables:

https://marketplace.thingworx.com/tools/Parsley_Extension

There is also another way you can do this purely within a JavaScript service if you have a datashape and you have an array of objects that matches that datashape. Here is how you can create a JSON representation of an InfoTable and then use the FromJSON snippet to transform it into a native InfoTable type:

//How to create an infotable from pure JSON

//create the JSON object to represent your infotable

var json = new Object();

//add the datashape definition

//this needs to be the correct datashape for your rows, in my example this is just a datahsape with a single string field called id

json.dataShape = DataShapes["DataShapeName"].GetDataShapeMetadataAsJSON();

  

//create a rows array

json.rows = [];

//add each row as an object

var row = new Object();

row.id = "idValue";

json.rows.push(row);

// result: INFOTABLE

var result = Resources["InfoTableFunctions"].FromJSON({json: json});