How get json value from array

Good morning,

I have a message like this:

{
   "dataflow":[
      {
         "date":"Dec 17, 2020 7:20 AM",
         "id":2,
         "cod":27,
         "value":676
      },
      {
         "date":"Dec 17, 2020 7:22 AM",
         "id":2,
         "cod":28,
         "value":670
      },
      {
         "date":"Dec 17, 2020 7:25 AM",
         "id":2,
         "cod":25,
         "value":717
      }
	]
}

I would retrieve and send data if cod==25 (example) with a function node or other node.
How can I do?
Thank you very much :slight_smile:

Use array find in a function

E.g...

msg.payload = msg.dataflow.find(e=>e.id==25);
return msg;

You could also replace the 25 with another msg property e.g.

msg.payload = msg.dataflow.find(e=>e.id==msg.find);
return msg;

Thank you very much Steve :slight_smile:

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