3
js = {
p1: {
qq: "qq_val",
},
p2: [{
qq: "qq_val",
}]
};
json = JSON.stringify(js);
console.log(json); // {"p1":{"qq":"qq_val"},"p2":[{"qq":"qq_val"}]}
Well, I just wanted to name the property, so it wouldn’t be empty, I tried something like:
js = {
p1: {
qq: "qq_val",
},
p2: [prop_name:{ // aqui eu coloco o nome da propriedade.
qq: "qq_val",
}]
};
json = JSON.stringify(js);
console.log(json); // {"p1":{"qq":"qq_val"},"p2":[{"qq":"qq_val"}]}
but accuses error, see: http://jsfiddle.net/61cmd6r3/
Maybe I’m scrambling some concepts (even basic), I expect a light from you so I understand better, I’m very confused..
What exactly do you want to do? Like
p2:
receives an array, you cannot name...– Sergio
This is called: Syntax error :)
– Wallace Maxters