I have a question regarding JavaScript. Let's say we have an object:
var someObject={"name":"somename"};
If we want to get the name from the object, we simply do:
alert(someObject.name); //this will print somename, right?
Now, if I receive the same object as JSON from a source like this:
someJSONObject={"name":"someName"};
In my JavaScript code, I can still access the name without parsing it like this:
alert(someJSONObject.name);
So my question is, why do we need to convert a JSON Object to a JavaScript Object by parsing it when we can use it directly as an object without parsing or using eval()
?
Thank you!