public static JSONObject getJsonByUrl(String url){
//String url = "a=1&b=2&c=3";
String[] strs= url.split("&");
JSONObject json = new JSONObject();
for (int i = 0; i < strs.length; i++) {
String[] s= strs[i].split("=");
if (s.length >= 2) {
String key = s[0];
String value = s[1];
for (int j = 2; j < s.length; j++) {
value += "=" + s[j];
}
try {
json.put(key,value);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
return json;
}
URL参数转JSON
最新推荐文章于 2023-11-23 16:23:09 发布