# Read data from JSON array

**URL:** <https://discourse.nodered.org/t/read-data-from-json-array/1938>\
**Category:** Dashboard\
**Created:** [31 July 2018 18:39 UTC](https://discourse.nodered.org/t/read-data-from-json-array/1938 "2018-07-31T18:39:06Z")\
**Posts on this page:** 1\
**Showing post:** 40

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [3 August 2018 11:19 UTC](https://discourse.nodered.org/t/read-data-from-json-array/1938/40 "2018-08-03T11:19:24Z")

</div>

> [@Ahd](#):
>
> Each object has two topics of data first is data which include time stamp and second is an image which includes image information.

That explains the issue. In such case test this code inside the function node. It will fetch the timestamp inside payload.data

```auto
let today = new Date().toDateString();

let extractor = function (elem) {
    let extr = new Date(elem.payload.data.timestamp).toDateString();
    return extr == today;
}
    
let output1 = msg.payload.filter(extractor);

let output2 = output1.sort(function (a, b) {
    let atime = new Date(a.payload.data.timestamp);
    let btime = new Date(b.payload.data.timestamp);
  return atime-btime;
});

let last = output2.pop();

node.warn(last);
msg.payload =last;

return msg;

```

---

_[View the full topic](https://discourse.nodered.org/t/read-data-from-json-array/1938)._
