I have a JSON string that is hard-coded into my page, it is used for settings in my application.
There is a use case where I need to add an option to those settings if a value is true.
From my psuedo code below, I am trying to add a "setting" to the main string if a value is true.
I tried to store the JSON as an array and then push my new data into it but java-script complained it wasn't in the right format.
How can I add the additional json data to my main string?
var v = true,
test = {
"copySelected": {
"name": "Copy",
"icon": "fa-files-o"
},
"sep1": "---------",
"success": {
"name": "Highlight: Green",
"icon": "fa-pencil"
},
"info": {
"name": "Highlight: Blue",
"icon": "fa-pencil"
},
"warning": {
"name": "Highlight: Yellow",
"icon": "fa-pencil"
},
"danger": {
"name": "Highlight: Red",
"icon": "fa-pencil"
},
"sep2": "---------",
"remove": {
"name": "Remove Highlight",
"icon": "fa-eraser"
},
"sep3": "---------",
"addNote": {
"name": "Add Note",
"icon": "fa-file-text-o"
}
}
// I need to add this section to the above json at the end
if(v){
"sep4": "---------",
"removeUser": {
"name": "Remove User",
"icon": "fa-user-times"
}
}