开发者

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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜