javascript对json数组对象修改值 如何根据json对象数组的value获取对应的key?
如何根据json对象数组的value获取对应的key?使用of语句对jsonArray循环遍历array怎么取里面所有的值?不需要写一个方法,把json数据转换成list子集数据statestatic
如何根据json对象数组的value获取对应的key?
使用of语句对jsonArray循环遍历
array怎么取里面所有的值?
不需要写一个方法,把json数据转换成list子集数据
statestaticListjsonToBean(Stringdata,Object bean){
ttListlistnextArrayList()
tttry{
tttJSONArrayarray
ttttry{
ttttarraynextJSONArray(data)
ttttfor(inti0iltarray.length()i){
tttttObjecttoBeangetBean(bean)
tttttJSONObjectobnextJSONObject()
tttttob(JSONObject)(i)
ttttttoBeanjsonStrToBean(ob,toBean)
(toBean)
tttt}
ttttreturnlist
ttt}catch(JSONExceptione){
tttttry{
tttttObjectparamsnull
tttttJSONObjectjsonObjnextJSONObject(data)
tttttObjecttoBeangetBean(bean)
ttttttoBeanjsonStrToBean(jsonObj,toBean)
(toBean)
tttttreturnlist
tttt}catch(JSONExceptione1){
(#34ErrorcovertStringneedJSONObject#34,e)
()
tttt}
()
(#34ErrorcovertStringwantJSONArray#34,e)
ttt}
tt}catch(SecurityExceptione){
()
tt}
ttreturnlist
t}
然后木盒list真包含于数据中的值应该绝对没问题了吧。