How to write a nested multi dimensional json object

后端 未结 4 2087
离开以前
离开以前 2021-02-05 12:56

I am studying json and i was wondering if this is the right way to write a multi dimensional json object that is nested.I wrote:

var foo = {
    \"logged_in\":tr         


        
4条回答
  •  暖寄归人
    2021-02-05 13:46

    Here is the proper format for your data (note i changed some data itself)

    {
        "logged_in":true,
        "town":"Dublin",
        "state":"Ohio",
        "country":"USA",
        "products":2,
        "productinfo":[
            {
                "0":{
                    "pic_id":"1500",
                    "description":"Picture of a computer",
                    "localion":"img.cloudimages.us/2012/06/02/computer.jpg",
                    "type":"jpg",
                    "childrenimages":2
                },
                "1":{
                    "pic_id":"15011",
                    "description":"Picture of a cpu",
                    "localion":"img.cloudimages.us/2012/06/02/mycpu.png",
                    "type":"png"
                },
                "2":{
                    "pic_id":"15012",
                    "description":"Picture of a cpu two",
                    "localion":"img.cloudimages.us/2012/06/02/thiscpu.png",
                    "type":"png"
                },
                "3":{
                    "pic_id":"1501",
                    "description":"Picture of a cpu",
                    "localion":"img.cloudimages.us/2012/06/02/cpu.png",
                    "type":"png"
                }
            }
        ]
    }
    

提交回复
热议问题