当前位置:编程学习 > wap >>

求助gson解析服务器返回json串的问题

java基础基本为零,感觉这个应该不是很难,就是不会。求各位大侠路见不平拔刀相助。
{"ok":true,"user":{"areaNo":"","birthday":null,"cityNo":"","department":"","email":"","gender":"","initPwd":"","isAdmin":"","loginId":"test11","loginName":"test11","manageLevel":"","markArea":"","marktainFlag":"","memo":"","mobilePhone":"","officeTel":"","password":"r547qTu+pmg=","regDate":null,"sectNo":"","sellArea":"","serviceArea":"","staffId":"test11","state":"","themes":"","townNo":"","updateDate":null,"updateUser":""}}
这个就是返回的json串,要用gson解析,其中user是要解析为user对象,表达的可能不是很清楚,求高人解答,在线等。 --------------------编程问答-------------------- RequestData requestData = new Gson().fromJson(jsonStr,RequestData.class);
 List<String>  list = requestData.getUser();
list里面就是user信息了
 
--------------------编程问答-------------------- gson解析很方便 --------------------编程问答-------------------- 那那个ok呢,是boolean的,我想知道是一次就能把boolean的ok和user对象都搞出来么
引用 1 楼  的回复:
RequestData requestData = new Gson().fromJson(jsonStr,RequestData.class);
 List<String>  list = requestData.getUser();
list里面就是user信息了
补充:移动开发 ,  Android
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,