I am creating a JSON object using JavaScript. How to insert the following data into the bottom of the stack:
"hello": { "label":"Hello", "url":"#hello" }
to the following variable:
var ListData = { "main": { "label":"Main", "url":"#main" }, "project": { "label":"Project", "url":"#project" }, "settings": { "label":"Settings", "url":"#settings", "subnav":[ { "label":"Privacy", "url":"#privacy" }, { "label":"Security", "url":"#security" }, { "label":"Advanced", "url":"#advanced" } ] } };
So the variable looks like this:
var ListData = { "main": { "label":"Main", "url":"#main" }, "project": { "label":"Project", "url":"#project" }, "settings": { "label":"Settings", "url":"#settings", "subnav":[ { "label":"Privacy", "url":"#privacy" }, { "label":"Security", "url":"#security" }, { "label":"Advanced", "url":"#advanced" } ] }, "hello": { "label":"Hello", "url":"#hello" } };
I used the following code, but it does not work:
var NewData = '"hello": { "label":"Hello", "url":"#hello" }'; ListData.push(NewData);