java--json嵌套数组解析(1)

json数据格式

{"data": [
  {
        "id": 3,
        "name": "16系列",
        "children": [
            {
                "id": 4,
                "name": "男鞋红色",
                "children": null,
                "parentId": 3,
                "image": "http://xxx608.png",
                "banner": null,
                "type": "category",
                "first_char": null,
                "enabled": true
            },
            {
                "id": 15,
                "name": "男鞋绿色",
                "children": null,
                "parentId": 3,
                "image": "http://xxx114.png",
                "banner": null,
                "type": "category",
                "first_char": null,
                "enabled": true
            },],
        "parentId": 0,
        "image": "http://xxxxx885.png",
        "banner": "http://xxxx_m.jpg",
        "type": "category",
        "first_char": null,
        "enabled": true
    },
    {
        "id": 3,
        "name": "17系列",
        "children": [
            {
                "id": 3,
                "name": "男鞋粉色",
                "children": null,
                "parentId": 3,
                "image": "http://xxx608.png",
                "banner": null,
                "type": "category",
                "first_char": null,
                "enabled": true
            },
            {
                "id": 12,
                "name": "男鞋黑色",
                "children": null,
                "parentId": 3,
                "image": "http://xxx114.png",
                "banner": null,
                "type": "category",
                "first_char": null,
                "enabled": true
            },],
        "parentId": 0,
        "image": "http://xxxxx885.png",
        "banner": "http://xxxx_m.jpg",
        "type": "category",
        "first_char": null,
        "enabled": true
    }
  ],
"status": {
    "succeed": 1,
    "error_code": null,
    "error_desc": null
    },
"paginated": null,
"session": null
}

java bean中定义java类,(这里省略setter、getter方法,自己补上)
java--json嵌套数组解析(1)_第1张图片

java--json嵌套数组解析(1)_第2张图片
值得注意的地方是,这里MobileBigCategory对应json中的data数组,MobileSmallCategory对应data中的children数组,需要在MobileBigCategory中定义ArrayList

你可能感兴趣的:(java,web)