JSON数据格式转换(StringBuffer拼接json串)大全及用法
JSON是基于{“键”:“值”} 对的存在,当然我们也可以多层嵌套,对于刚刚学习JSON十分便捷而且很好用,很容理解。话不多说直接上代码: public String queryPostInterface(String theNewInterface) throws Exception { JSONObject jsonObject = new JSONObject(theNewInterface); String postId = AESUtil.Decrypt(jsonObject.getString("post_id"), cKey);//帖子ID StringBuffer sb = new StringBuffer(); int size = 0;//定义一个变量用来接收循环多少次(共多少条数据) if(theNewInterface!=null && !"".equals(theNewInterface)){ if (postId != null && !"".equals(postId)) { //获取帖子信息 tieba(具体业务自己查询这里只是个例子) TyPostInfo postInfo = tyPostBarService.selpostInfoById(Long.valueOf(postId)); //查询帖子回复信息(具体业务自己查询这里只是个例子)(