String josnString = "{'name':'zhang'}";
if(josnString != null){
//取空格 换行 回车
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
Matcher m = p.matcher(josnString.toString());
String after = m.replaceAll("");
try {
//取对象名 JSONObject a = new JSONObject(after); System.out.println(a.get("name")); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); }}
原文链接:https://www.f2er.com/json/290727.html