Node red table formatting with condition

for the table node

the suggested format is

[
    {
        "Name": "Kazuhito Yokoi",
        "Age": "35",
        "Favourite Color": "red",
        "Date Of Birth": "12/09/1983"
    },
    {
        "Name": "Oli Bob",
        "Age": "12",
        "Favourite Color": "cyan",
        "Date Of Birth": "12/08/2017"
    }
]

however,
if i want to do some condition check or while inside
like

for (var i = 0; i<ct; i++)
{

 myJsondata =    
    {
        "a": (msg.payload.data.devices[i].datastreams[0]                
    },
        
    if(((msg.payload["1"].data.devices[i].datastreams[0].value.split(','))[0] == msg.payload["2"][1]["b"]))
    {
        "a": (msg.payload.data.devices[i].datastreams[1]
   }      
}           

the above will fail if i put the for loop OR if condition inside the json for table
can anyone help?

You need to build an array or data lines... you seem to be creating a single object that isn't in an array.

thanks.
but
i have two payload for operation check...
can i do the check in array ?

Yes, generally you would use push( to add items to an array in a loop.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.