开发者

How can I properly create a nested JSON object?

开发者 https://www.devze.com 2023-03-18 19:11 出处:网络
When I pass this through a JSON lint it doesn\'t appear as a nested JSON. How can I make this JSON nested properly?

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

精彩评论

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