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

Error Reading Json Element in Array with Dash "-" in Name

SOLVED
Highlighted
Participant

Error Reading Json Element in Array with Dash "-" in Name

I'm trying to create an infotable from a JSON array that is in a logged property.  The problem is that one of the elements in the array has a dash in the name ("arc-time").  I cannot change the element but can't get it to come through.  The following code gives me an error: "missing name after .operator".  Any ideas?

var obj= me.ErrorHistory;

var params = {
    infoTableName: "InfoTable",
    dataShapeName : "ErrorHistory_Shape"
};

var infotabletest = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

for(var i=0; i<obj.array.length; i++)

{

    infotabletest.AddRow({"id":obj.array.id,"type":obj.array.class,"arctime":obj.array.["arc-time"]});
}

var result= infotabletest;

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Error Reading Json Element in Array with Dash "-" in Name

When you get a field value with ["arc-time"] no "." should be written, then your instruction should be:

infotabletest.AddRow({"id":obj.array.id,"type":obj.array.class,"arctime":obj.array["arc-time"]});

3 REPLIES 3

Re: Error Reading Json Element in Array with Dash "-" in Name

What is your Thingworx platform version?

I will recreate, and if a bug is confirmed, submit a jira.

Re: Error Reading Json Element in Array with Dash "-" in Name

When you get a field value with ["arc-time"] no "." should be written, then your instruction should be:

infotabletest.AddRow({"id":obj.array.id,"type":obj.array.class,"arctime":obj.array["arc-time"]});

Re: Error Reading Json Element in Array with Dash "-" in Name

That worked Carles!.  I knew it was something small. Thanks!