Recently, I've been working on parsing JSON in JavaScript
{"success":{"id_user":"1",
"username":"nasir",
"password":"f30aa7a662c728b7407c54ae6bfd27d1"}}
I successfully parsed the JSON using the following code snippet
var obj = JSON.parse(result); // result contains the JSON mentioned above
console.log(obj.success); // to display the JSON in the console
However, I encountered an issue when trying to retrieve the value of the username element using the following code snippet
console.log("testing "+obj.success[0].username);
This resulted in the error message: Uncaught TypeError: Cannot read property 'username' of undefined
I have attempted various approaches to resolve this issue but have not succeeded. Any suggestions on where I might be making a mistake would be greatly appreciated.
Thank you