i used this code in nodejs to get data from json but gets error and say undefined
var obj = {payload:'fp_2'};
var myJSON = JSON.stringify(obj);
console.log(myJSON.payload); //output: undefined
and i have same error in javascript
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var obj = {payload:'fp_2'};
var myJSON = JSON.stringify(obj);
document.getElementById("demo").innerHTML = myJSON.payload;
</script>
</body>
</html>
what is my error? can any one help me...
JSON.stringify()is just a simple string; there's no "payload" property. You can examineobj.payloadbecause that makes sense. Once you.stringify()it however you just have a string. There's no need to "parse" an object that's declared with an object initializer expression; the object already exists and is ready for use.JSON.stringify(obj)does? It stringifies the object. It returns a string. If you only need thepayloadproperty, you don't need to stringify.