生成json数据示例

来源:互联网 发布:电视网络机顶盒什么牌子好 编辑:程序博客网 时间:2024/06/11 15:37
public static JSONObject jsonTest(){JSONObject jsonObject = null;JSONObject userCommentJson = null;JSONArray data = new JSONArray();try{for (int i = 0; i < 10; i++) {userCommentJson = new JSONObject();  userCommentJson.put("userContent", "说的好");userCommentJson.put("replyUserName", "普京");userCommentJson.put("replyUserId", "10");userCommentJson.put("replyCommentId", "2");userCommentJson.put("goodNum", "499");userCommentJson.put("userToken", "1");userCommentJson.put("userCodeId", "1(腾讯qq)");userCommentJson.put("userHead", "");userCommentJson.put("userCity", "深圳");data.put(userCommentJson);}jsonObject = new JSONObject();  jsonObject.put("state", "1");jsonObject.put("data", data);}catch(JSONException e) {// TODO Auto-generated catch blocke.printStackTrace();}return jsonObject;       }

0 0