JSON.parse Syntax: JSON.parse(text[, reviver]) Parameters: text-The string to parse as JSON. reviver- Optional If a function, this prescribes how the value originally produced by parsing is transformed, before being returned. Return value The Object corresponding to the given JSON text.
I really don't understand this. I have a JSON file that I need to use the data within to populate the DOM but I don't understand JSON.parse. When I tried to use this I used
var myData = JSON.parse({ "site": { "id": "example", "name": "example1" }...etc});
then tried to access it using dot notation.
console.log(myData.site.id);
I don't know what I'm doing, I've now figured out 200+ ways not to do it
JSON.parse()in your sample.