How to select an Object in payload

Dear friends,
I faced a very simple problem that confused me !
I have such a payload :

4/25/2020, 12:07:15 AMnode: 6c705480.72452c
msg.payload : Object
object
number: ""12817""
date: ""20/04/24"
time: "22:10:00+18"↵"

and I want to put an If statement in function node.
I try both of these ,but none worked !

if(msg.payload.number == "12817")
{
    return msg;
}

and also :

if(msg.payload.number === "12817")
{
    return msg;
}

So whats the problem ?

Send it to the debug window, expand the msg, click the item of interest then click the middle button to copy the variables path.

Also, read this - spend 10 minutes reading this. Well worth it.

Your object values are JSON strings for some reason. you would have to do a JSON.parse() for each key value pair.
That’s why you see the double "" on each side of the values.

Where does that data come from? You have probably done something not the best way in getting that data in the first place. Such as not converting a JSON string to an object rather than trying to extract data manually from a JSON string.

Exactly ! :heart:
I try :

if(JSON.parse(msg.payload.number) == "12817")

and it works ....
Thanks

yeah, but as @Colin states, its not normal to have to do that.

show your flow & we'll see if we can correct it.

Thanks for the point .
It is a part of long flow ,
I try to solve that problem else ,
I learn 2 simple but important points , Thanks All ..