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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

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

rflanagan
5-Regular Member

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;

1 ACCEPTED SOLUTION

Accepted Solutions

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"]});

View solution in original post

3 REPLIES 3
posipova
20-Turquoise
(To:rflanagan)

What is your Thingworx platform version?

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

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"]});

rflanagan
5-Regular Member
(To:CarlesColl)

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

Top Tags