I have a JSON data that needs to be filtered based on three values. I have managed to filter based on two values, "timestamp" which is not nested, but I am struggling with the nested value "fromMe".
While I can easily access the "timestamp" value as it is not nested, I am unable to filter based on x.lastMsg.id.fromMe.
Here is the JavaScript code snippet:
var filterMessages = chats_ativo.filter(function(x){
return x.timestamp >= variable1 && x.timestamp <= variable2; /* working */
return x.timestamp >= variable1 && x.timestamp <= variable2 && x.lastMsg.id.fromMe == false; /* not working */
});
And here is a snippet of the JSON data logged in the console (personal info removed):
"id": {
"server": "c.us",
"user": "phonenumber",
"_serialized": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="afdfc7c0c1cac1dac2cdcaddefcc81dadc">[email protected]</a>"
},
"name": "Name",
"isGroup": false,
"isReadOnly": false,
"unreadCount": 0,
"timestamp": 1596167676,
"archived": false,
"lastMsg": [
{
"id": {
"fromMe": false,
"remote": {
"server": "c.us",
"user": "phonenumber",
"_serialized": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7d0d151213181308101f180f3d1e53080e">[email protected]</a>"
},