JSONObject 转换为 request 参数

来源:互联网 发布:时代周刊封面 知乎 编辑:程序博客网 时间:2024/05/22 15:33
private String jsonObjToRequestStr(JSONObject json, int length) {StringBuilder str;Iterator it;try {str = new StringBuilder();if (length > 0) {it = json.keys();while (it.hasNext()) {String name = it.next().toString();try {str.append(name).append("=").append(json.get(name)).append("&");} catch (JSONException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}return str.substring(0, str.length() - 1).toString();} finally {json = null;str = null;it = null;}}

0 0