I have been trying to use JLinq for filtering JSON data, but I am facing an issue with filtering by date. Despite attempting different methods, the problem persists.
Below is a snippet of my code:
//This works
jlinq.from(myData)
.select(function(rec) {
return {
title: rec.title,
pubDate: rec.pubDate
}
});
This is the data returned by the above code:
// And returned this data
myData = [
{pubDate: "2012-06-19T10:42:59.000Z",
title: "How caching matters in JS?" },
{pubDate: "2012-06-18T14:39:25.000Z",
title: "Globbing in scripting languages"},
{pubDate: "2012-06-14T17:50:22.000Z",
title: "Inspecting Objects in Scripting"}
]
When I attempt to filter by date (greater than or less than), it does not work as expected.
EDITED
//Filter by pubDate
jlinq.from(myData)
.greater(new Date("pubDate"), new Date("2010-02-13T19:03:17.000Z"))
.select();
This issue seems to arise specifically when comparing Date values, resulting in an empty array being returned.
//But Returns empty Array
//[]