知道了问题出在哪里,就得想办法解决。首先想到的是百度,可是一阵之后未果。数据库及服务端都不是自己做,改数据库及服务端都不现实,只有在android上考虑,服务端做也就是把返回的Json字段的首字母弄小写,或改数据表里的字段,好吧,说到这里,也就不卖关子了,解决方法很简单,直接给Json字符串toLowerCase()一把再转换成JsonObject,这时javabean就可以统统用小写处理。
关键代码: JSONObject jObject = new JSONObject(resource.toLowerCase(Locale.getDefault()));
{
"res": "1","index_banner": [
{
"Ad_Name": "手机滚动大图一","Ad_Link": "/huodong/fabuhui.html","Ad_Code": "/UpLoads/image/20140910/20140910172048_31579.jpg"
},{
"Ad_Name": "手机滚动切换五","Ad_Link": "http://m.toptuu.com/Huodong/danye.html","Ad_Code": "/UpLoads/image/20140906/20140906084953_94943.jpg"
},{
"Ad_Name": "手机滚动切换四","Ad_Link": "/Huodong/dingzhi.html","Ad_Code": "/UpLoads/image/20140906/20140906085053_90516.jpg"
},{
"Ad_Name": "手机滚动切换三","Ad_Link": "/Huodong/jiu.html","Ad_Code": "/UpLoads/image/20140906/20140906085138_32961.jpg"
},{
"Ad_Name": "手机滚动大图二","Ad_Link": "/huodong/jy.html","Ad_Code": "/UpLoads/image/20140910/20140910152954_72484.jpg"
},{
"Ad_Name": "手机切换0","Ad_Link": "/Huodong/xifeng.html","Ad_Code": "/UpLoads/image/20140830/20140830115112_40561.jpg"
}
]
}
解决方法很简单,但是确实让我琢磨了很久,只要是问题就值得记录下来,总会帮到别人的。
原文链接:https://www.f2er.com/json/288967.html