本文介绍了如何使用GSON解析JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的Json响应如下,并混淆了如何使用GSON进行解析.请查看以下内容,并指导我如何使用GSON进行解析.
My Json response is something as below and confused how to parse it using GSON.Please have look on the following and guide me how i can parse it using GSON.
{
"GetMICSDataResult": {
"CONVERTIONFACT": [
{
"CONVERSIONFACT": "1",
"ITEMNO": "S1300W",
"UOM": "Ea."
},
{
"CONVERSIONFACT": "1",
"ITEMNO": "S1300Y",
"UOM": "Ea."
}
],
ITEMDETAILS": [
{
"ITEMDESC": "FluorescentDeskLamp",
"ITEMNO": "A11030",
"LOCATION": "1",
"PRICELIST": "WHS",
"QTYONHAND": 164,
"UNITPRICE": 38.3,
"UOM": "Ea."
},
{
"ITEMDESC": "FluorescentDeskLamp",
"ITEMNO": "A11030",
"LOCATION": "2",
"PRICELIST": "WHS",
"QTYONHAND": 247,
"UNITPRICE": 38.3,
"UOM": "Ea."
}
]
}}
推荐答案
有简单的方法可以做到这一点.只需使用POJO生成器 http://www.jsonschema2pojo.org/,它将为您提供带有必要注释的普通对象.您也可以使用Json格式化程序来验证JSON https://jsonformatter.curiousconcept.com/-JSON您发布的内容无效.
There is easy way to do that. Just use POJO generator http://www.jsonschema2pojo.org/ it will give you plain object with necessary annotations. also you can use Json formatter to validate your json https://jsonformatter.curiousconcept.com/ - the JSON you posted is invalid.
这篇关于如何使用GSON解析JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!