【Java】使用jackson解析一个复杂格式的json

`{

"result": {

"1016791455_3368358963": {

"icon_url": "-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KW1Zwwo4NUX4oFJZEHLbXK9QlSPcUmvAhWTV7CCOOh1szaXFB1Nw1Zs4WrLgRrnPTEcD5L49G3homFksj6Nrja2G9SvcMli7CTpNz221exrkFlYT3yIICQegU7aArUqQDqkOvn0ce_6p3XiSw0eaYI3eY",

"icon_url_large": "-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KW1Zwwo4NUX4oFJZEHLbXK9QlSPcUmvAhWTV7CCOOh1szaXFB1Nw1Zs4WrLgRrnPTEcD5L49G3homFksj6NrjaqWdQ-sJ0xO_A9Nmt2wLhqRI4NWjzIIHBelc7Zl_UqVK6ye_n0cO-6syfwXtnu3U8pSGKlzm7ilw",

"icon_drag_url": "",

"name": "Inscribed Tusks of the Glacier Sea",

"market_hash_name": "Inscribed Tusks of the Glacier Sea",

"market_name": "Inscribed Tusks of the Glacier Sea",

"name_color": "CF6A32",

"background_color": "",

"type": "Common Tusks",

"tradable": "0",

"marketable": "0",

"commodity": "0",

"market_tradable_restriction": "7",

"market_marketable_restriction": "0",

"fraudwarnings": "",

"descriptions": {

"0": {

"type": "html",

"value": "Used By: Tusk",

"app_data": ""

},

"1": {

"type": "text",

"value": "Gift From: 只想上点分BH",

"color": "99ccff",

"app_data": ""

},

"2": {

"type": "html",

"value": "Date Received: Jun 4, 2015 (20:12:02)",

"app_data": ""

},

"3": {

"type": "html",

"value": " ",

"app_data": ""

},

"4": {

"type": "html",

"value": "Brawler of the Glacier Sea",

"color": "9da1a9",

"app_data": {

"def_index": "20834",

"is_itemset_name": "1"

}

},

"5": {

"type": "html",

"value": "Coat of the Glacier Sea",

"color": "6c7075",

"app_data": {

"def_index": "9012"

}

},

"6": {

"type": "html",

"value": "Rudder of the Glacier Sea",

"color": "6c7075",

"app_data": {

"def_index": "9011"

}

},

"7": {

"type": "html",

"value": "Hook of the Glacier Sea",

"color": "6c7075",

"app_data": {

"def_index": "9010"

}

},

"8": {

"type": "html",

"value": "Anchor of the Glacier Sea",

"color": "6c7075",

"app_data": {

"def_index": "9009"

}

},

"9": {

"type": "html",

"value": "Tusks of the Glacier Sea",

"color": "6c7075",

"app_data": {

"def_index": "9008"

}

},

"10": {

"type": "html",

"value": "Cap of the Glacier Sea",

"color": "6c7075",

"app_data": {

"def_index": "9007"

}

},

"11": {

"type": "html",

"value": "Frozen Sigil of the Glacier Sea",

"color": "6c7075",

"app_data": {

"def_index": "9006"

}

},

"12": {

"type": "html",

"value": " ",

"app_data": ""

},

"13": {

"type": "html",

"value": "( Not Tradable )",

"app_data": ""

},

"14": {

"type": "html",

"value": "<div style=\"white-space: nowrap; margin: 10px\"><div style=\"white-space: nowrap; padding: 3px;\"><div style=\"width: 60px; height: 32px; vertical-align: top; display: inline-block;\"><div style=\"position: relative; width: 48px; height: 32px; vertical-align: top; display: inline-block; border: 2px solid rgb(255, 255, 255);\"><div style=\"position: absolute; width: 48px; height: 32px; vertical-align: top; display: inline-block; background-size: contain; background-image: url(https://steamcdn-a.akamaihd.net/apps/570/icons/econ/sockets/gem_spectator.9dbff8e11aea0425dc376bec672c03dc92f7bab9.png)\"></div></div></div><div style=\"vertical-align: top; display: inline-block; margin-left: 12px padding: 2px\"><span style=\"font-size: 18px; white-space: normal; color: rgb(255, 255, 255)\">ViCi Gaming</span><br><span style=\"font-size: 12px\">Games Watched: 3</span></div></div><div style=\"white-space: nowrap; padding: 3px;\"><div style=\"width: 60px; height: 32px; vertical-align: top; display: inline-block;\"><div style=\"position: relative; width: 48px; height: 32px; vertical-align: top; display: inline-block; border: 2px solid rgb(255, 255, 255);\"><div style=\"position: absolute; width: 48px; height: 32px; vertical-align: top; display: inline-block; background-size: contain; background-image: url(https://steamcdn-a.akamaihd.net/apps/570/icons/econ/sockets/gem_stat.30d7935c1f0a1b9e8e28c691c2bd28f7d5f471bc.png)\"></div></div></div><div style=\"vertical-align: top; display: inline-block; margin-left: 12px padding: 2px\"><span style=\"font-size: 18px; white-space: normal; color: rgb(255, 255, 255)\">Walrus Punches: 53</span><br><span style=\"font-size: 12px\">Inscribed Gem</span></div></div></div>",

"app_data": ""

}

},

"owner_descriptions": "",

"tags": {

"0": {

"internal_name": "strange",

"name": "Inscribed",

"category": "Quality",

"color": "CF6A32",

"category_name": "Quality"

},

"1": {

"internal_name": "Rarity_Common",

"name": "Common",

"category": "Rarity",

"color": "b0c3d9",

"category_name": "Rarity"

},

"2": {

"internal_name": "wearable",

"name": "Wearable",

"category": "Type",

"category_name": "Type"

},

"3": {

"internal_name": "neck",

"name": "Neck",

"category": "Slot",

"category_name": "Slot"

},

"4": {

"internal_name": "npc_dota_hero_tusk",

"name": "Tusk",

"category": "Hero",

"category_name": "Hero"

}

},

"classid": "1016791455",

"instanceid": "3368358963"

},

"success": true

}

}`

这是json的返回格式,是通过spring的resttemplate请求返回的结果,
如果把它解析成一个定义好的对象。
以及如何写这个对象的字段

回答

一个对象是搞不定的吧。需要拆分出来多个对象吧?
简单写一下,自己拓展吧。
要把每一层当做一个对象,这样上层是对象,下一层也是对象,但是下一层这个对象还是上层的一个属性。类似于:
【Java】使用jackson解析一个复杂格式的json

以上是 【Java】使用jackson解析一个复杂格式的json 的全部内容, 来源链接: utcz.com/a/89708.html

回到顶部