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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

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

rflanagan
8-Gravel

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;

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

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

Announcements


Top Tags