Check if a key exists inside a json object

后端 未结 9 1387
旧巷少年郎
旧巷少年郎 2020-11-29 14:48
amt: \"10.00\"
email: \"sam@gmail.com\"
merchant_id: \"sam\"
mobileNo: \"9874563210\"
orderID: \"123456\"
passkey: \"1234\"

The above is the JSON o

9条回答
  •  长情又很酷
    2020-11-29 15:44

    Try this,

    if(thisSession.hasOwnProperty('merchant_id')){
    
    }
    

    the JS Object thisSession should be like

    {
    amt: "10.00",
    email: "sam@gmail.com",
    merchant_id: "sam",
    mobileNo: "9874563210",
    orderID: "123456",
    passkey: "1234"
    }
    

    you can find the details here

提交回复
热议问题