Check if a key exists inside a json object

后端 未结 9 1388
旧巷少年郎
旧巷少年郎 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:39

    Type check also works :

    if(typeof Obj.property == "undefined"){
        // Assign value to the property here
        Obj.property = someValue;
    }
    

提交回复
热议问题