<>复杂json数据的解析
<求助>复杂json数据的解析
请求接口,返回这样的多层嵌套的json数据。一两层还能解析。复杂的就傻眼了。另外使用gsonFormat生不成实体类,自己拆分,写的实体类,解析不出来。好坑。求助各位,不吝赐教。
json 数据如下。 {
"data": {
"id": 39,
"name": "商标注册--测试",
"productAttributes": [
{
"addressAttribute": [
{
"addressAttributes": [],
"addressName": "大陆地区",
"associatedProductId": 40,
"attributeValueTypeId": 10,
"cost": 600.0000,
"id": 74,
"isParent": false,
"isPreSelected": false,
"name": "大陆地区",
"picture": {},
"price": [
{
"name": "服务费",
"value": "0.0000"
},
{
"name": "成本",
"value": "600.0000"
}
],file:/C:/Users/Administrator/Desktop/10-8/Nop_Android/app/src/main/java/com/dshh/wlq/nop_android/ui/detail/ProductDetailsActivity.java
"priceAdjustment": 600.0000,
"priceAdjustmentValue": 0
}
],
"allowedFileExtensions": [],
"attributeControlType": 1,
"description": "<p>所在区县</p>",
"id": 27,
"isRequired": false,
"name": "所在区县",
"productAttributeId": 1,
"productId": 39,
"textPrompt": "addr",
"values": []
}
],
"productPrice": {
"callForPrice": false,
"currendyCode": "CNY",
"customerEntersPrice": false,
"displayTaxShippingInfo": false,
"hidePrices": false,
"isRental": false,
"price": "¥0.00",
"priceValue": 0,
"priceWithDiscountValue": 0,
"productId": 39
},
"relateProducts": [],
"tierPrices": []
},
"success": true,
"takenTime": 93.7522,
"token": {
"expires": 714501,
"timestamp": 1445701762
}
}
------解决思路----------------------
gsonformat怎么生不成实体类?
http://blog.****.net/crazy1235/article/details/48598803#gosnformat
------解决思路----------------------
你一层一层解析呗,从外面开始。先去拿这个json测试了,然后再简单封装一下
------解决思路----------------------
http://www.jsonschema2pojo.org/ 在线Json转POJO,Source type选择JSON,Annotation style选Gson,之后点击Preview按钮即可自动转换成POJO。
------解决思路----------------------
网上下载一个谷歌Gson的jar包,然后用Gson解析比较快,也是一层一层的剥,需要哪层就剥到哪层
请求接口,返回这样的多层嵌套的json数据。一两层还能解析。复杂的就傻眼了。另外使用gsonFormat生不成实体类,自己拆分,写的实体类,解析不出来。好坑。求助各位,不吝赐教。
json 数据如下。 {
"data": {
"id": 39,
"name": "商标注册--测试",
"productAttributes": [
{
"addressAttribute": [
{
"addressAttributes": [],
"addressName": "大陆地区",
"associatedProductId": 40,
"attributeValueTypeId": 10,
"cost": 600.0000,
"id": 74,
"isParent": false,
"isPreSelected": false,
"name": "大陆地区",
"picture": {},
"price": [
{
"name": "服务费",
"value": "0.0000"
},
{
"name": "成本",
"value": "600.0000"
}
],file:/C:/Users/Administrator/Desktop/10-8/Nop_Android/app/src/main/java/com/dshh/wlq/nop_android/ui/detail/ProductDetailsActivity.java
"priceAdjustment": 600.0000,
"priceAdjustmentValue": 0
}
],
"allowedFileExtensions": [],
"attributeControlType": 1,
"description": "<p>所在区县</p>",
"id": 27,
"isRequired": false,
"name": "所在区县",
"productAttributeId": 1,
"productId": 39,
"textPrompt": "addr",
"values": []
}
],
"productPrice": {
"callForPrice": false,
"currendyCode": "CNY",
"customerEntersPrice": false,
"displayTaxShippingInfo": false,
"hidePrices": false,
"isRental": false,
"price": "¥0.00",
"priceValue": 0,
"priceWithDiscountValue": 0,
"productId": 39
},
"relateProducts": [],
"tierPrices": []
},
"success": true,
"takenTime": 93.7522,
"token": {
"expires": 714501,
"timestamp": 1445701762
}
}
------解决思路----------------------
gsonformat怎么生不成实体类?
http://blog.****.net/crazy1235/article/details/48598803#gosnformat
------解决思路----------------------
你一层一层解析呗,从外面开始。先去拿这个json测试了,然后再简单封装一下
------解决思路----------------------
http://www.jsonschema2pojo.org/ 在线Json转POJO,Source type选择JSON,Annotation style选Gson,之后点击Preview按钮即可自动转换成POJO。
------解决思路----------------------
网上下载一个谷歌Gson的jar包,然后用Gson解析比较快,也是一层一层的剥,需要哪层就剥到哪层