JSON to Infotable Problem
Hi there, I'm trying to get data from a JSON format into an infotable. Just as a try I want to get the unit "kWh" into the table. For that I designed a data shape with a single text field. Problem is the created table is empty. As raw JSON format the data is presented just fine. Do you see an error? Cheers, Nils
Here is my code so far, based on the instructions from here: https://community.ptc.com/t5/ThingWorx-Developers/About-Convert-JSON-file-to-Infotable/m-p/508236?source=Article%2520viewer
var params = {
proxyScheme: undefined /* STRING */,
headers: undefined /* JSON */,
ignoreSSLErrors:true,
useNTLM: undefined /* BOOLEAN */,
workstation: undefined /* STRING */,
useProxy: undefined /* BOOLEAN */,
withCookies: undefined /* BOOLEAN */,
proxyHost: undefined /* STRING */,
url: "http://xxxxx",
timeout: undefined /* NUMBER */,
proxyPort: undefined /* INTEGER */,
password:"xxx",
domain: undefined /* STRING */,
username:"xxx"
};
// result: JSON
var json = Resources["ContentLoaderFunctions"].GetJSON(params);
var params2 = {
infoTableName : "InfoTable",
dataShapeName : "Berg1_Shape"
};
//result INFOTABLE
var jsonTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params2);
for(var i=0; i<5; i++) {
jsonTable.AddRow({Value:json.values.unit});
}
result=jsonTable;
And this is the JSON input:
{
"self": {
"href": "https://xxxxx"
},
"version": 2,
"values": [
{
"unit": "kWh",
"time": "2018-08-30T22:15:00Z",
"value": 0.01
},
{
"unit": "kWh",
"time": "2018-08-30T22:30:00Z",
"value": 0.3
},
....

