首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

android开发、施用Json传递数据

2012-07-18 
android开发、使用Json传递数据、//记录一下、留给自己的、public static ListFollower loadFollowerList(in

android开发、使用Json传递数据、

//记录一下、留给自己的、public static List<Follower> loadFollowerList(int uid) {try {list = new ArrayList<Follower>();JSONObject jsonObject = new JSONObject();jsonObject.put(Constants.JSON_ID, 1);jsonObject.put(Constants.JSON_METHOD, Constants.FOLLOWERLIST_QUERY);JSONObject jsonObject_param = new JSONObject();jsonObject_param.put(Constants.UID, uid);jsonObject.put(Constants.JSON_PARAMS, jsonObject_param);jsonObject.put(Constants.JSON_RPC, Constants.RCP_NO);String responseString = HttpManager.executePost(Constants.URL_STRING, jsonObject.toString());JSONObject resultObject = new JSONObject(responseString);JSONArray jsonArray = resultObject.getJSONArray(Constants.RESULT);for (int i = 0; i < jsonArray.length(); i++) {follower = new Follower();follower.setFollowerName(jsonArray.getJSONObject(i).getString("followername"));follower.setFollowerPic(jsonArray.getJSONObject(i).getString("followerpic"));}} catch (Exception e) {System.out.println("error");e.printStackTrace();}return list;}/**传入: {"id":1,"method":"followerlist.query","params":{"uid":"7"},"jsonrpc":"2.0"}从传出的Json对象解析需要的内容*/

热点排行