How can I properly create a nested JSON object?
When I pass this through a JSON lint it doesn't appear as a nested JSON. How can I make this JSON nested properly?
var c = {
"io_name" : "Fruits",
"io_children" : [{
"io_name":"banana",
"io_name":"ap开发者_如何学JAVAple",
"io_name":"pear"
}]
}
Did you mean this?
var c = {
"io_name" : "Fruits",
"io_children" : [
{"io_name":"banana"},
{"io_name":"apple"},
{"io_name":"pear"}
]
}
As it is, you're declaring an array that contains one object, and the object defines one key "io_name" and then redefines the value of that key three times (which is illogical at best)
精彩评论