I am trying to write a JSON file using JQuery. I am attempting to use a javascript object as a json key however it does not run. My code is:
var lvl = 2;
$.getJSON( "json/levels.json", function(levels) {
levels.level.push({
lvl:[{
"Test": "some text"
}]
}
);
This outputs:
{
"level": [{
"lvl": [{
"Test": "Some Text",
}]
}]
}
However, it should be returning:
{
"level": [{
"2": [{
"Test": "Some Text",
}]
}]
}
What am I doing wrong?
Thanks Nick