Is there a way to add a condition to JSON.parse()?

Hi @ed_truqc,
You can make use of filter and MomentJS that’s included with Postman to filter your JSON array based on the created date. Assuming your created is of date type. You can use the following sample snippet to filter your array.

let moment = require('moment'),
    dateToday = moment();

filteredJSONData = reportJSONData.filter((reportJSON) => {
 // reportJSON.created is the created attribute that is in your array
 return dateToday.diff(reportJSON.created, 'days') > 60;
});

console.log(filteredJSONData);

Your filterJSONData will have all the records with the filter (60 days here)

1 Like