Code Bye

如何用json-lib、fastjson解析这种复合类型对象

数据格式如下——
{
    “requestId”: 63,
    “callBack”: “http://192.168.17.57:8880/activation-engine/responseApi/account”,
    “createdTime”: 1398431223,
    “customer”: {
        “id”: 111357,
        “name”: “China cc com”,
        “customerCode”: “024014”,
        “contract”: {
            “id”: 111357,
            “resource”: {
                “siteURL”: “china.com”
            },
            “components”: [
                {
                    “name”: “qq”,
                    “activationUrl”: “http://192.168.17.57:8880/mis-middleware/api/activate”,
                    “property”: {
                        “1”: “1”,
                        “2”: “3,4,5”,
                        “3”: “6”,
                        “4”: “8”,
                        “5”: “20”,
                        “6”: “22”,
                        “7”: “23”,
                        “8”: “25,26,258,259”,
                        “9”: “27”,
                        “10”: “28”,
                        “11”: “30”,
                        “12”: “397”,
                        “13”: “35,36,37,38,405,406,407,408”,
                        “14”: “39”,
                        “15”: “42,43”,
                        “16”: “44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64”,
                        “17”: “65”,
                        “18”: “66”,
                        “19”: “68”,
                        “20”: “338”,
                        “22”: “74”,
                        “23”: “76,77,78”,
                        “24”: “79,80,81”,
                        “25”: “82”,
                        “27”: “85”,
                        “28”: “87”,
                        “29”: “88”,
                        “30”: “90”,
                        “31”: “92”,
                        “32”: “96”,
                        “33”: “98,99,100”,
                        “34”: “101”,
                        “35”: “103”,
                        “45”: “138”,
                        “61”: “69”,
                        “63”: “93,94”,
                        “71”: “185,186,187”,
                        “72”: “188”,
                        “73”: “403”,
                        “74”: “192”,
                        “75”: “194”,
                        “76”: “196”,
                        “77”: “198”,
                        “89”: “222,223,224,225,226,227,228,229,230,231,232”,
                        “90”: “233,234,235,236,237,238,239,240,343,344,345,346,347,350,351”,
                        “91”: “241,242,243,244,245,246,247,248,353,354”,
                        “92”: “250,251,252,253,254,255,256,257,340,341,352,393”,
                        “93”: “260,261,262,263,264,348,349”,
                        “94”: “265,266,267,268”,
                        “95”: “272,273,274”,
                        “102”: “311,312,313,314,315,316,317,318,319,320,321”,
                        “103”: “322,323,324,325,326,327,328,329,330,331,332”,
                        “104”: “333,334,335,336,337”,
                        “105”: “356”,
                        “106”: “357”,
                        “107”: “359,360,395”,
                        “108”: “361,362,396”,
                        “109”: “378”,
                        “110”: “380”,
                        “confscale”: “200”,
                        “time2”: “45”,
                        “time1”: “45”,
                        “productid”: “”,
                        “bridgeName”: “sum”,
                        “cycle”: “0”,
                        “reservtime”: “”,
                        “starttime”: “”,
                        “cmccminutes”: “1440”,
                        “roles”: “4,5”,
                        “language”: “2”,
                        “ifpasswordfixed”: “1”,
                        “valid”: “1”,
                        “cmccdesc”: “”,
                        “cmccname”: “QQ”,
                        “realreserve”: “1”,
                        “callout”: “0”,
                        “applicationID”: “”,
                        “billingcode”: “”,
                        “stopwhenoneuser”: “1”,
                        “pin”: “0”
                    }
                }
            ]
        }
    },
    “type”: “create”
}


50分
fastjson不是可以直接装到bean里面么
如果直接拿的话就是geString,getObject这样的,参数是json的key
然后好像我只会一层层get出来
直接取到好几层里面的不知道有没有方便的办法

50分
fastjson解析这种嵌套对象没什么问题,你的Pojo对象里面定义好子对象,每个属性名在你的pojo中一一对应写好private 成员变量

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明如何用json-lib、fastjson解析这种复合类型对象