首先添加maven依赖
1 <dependency>2 ????????????<groupId>org.json</groupId>3 ????????????<artifactId>org.json</artifactId>4 ????????????<version>chargebee-1.0</version>5 </dependency>
string转json
1 public static JSONObject strToJson(String str) throws JSONException{2 ????????str = "{\"code\":\"0\",\"msg\":\"success\",\"data\":{\"taskStatus\":1}}";3 ????????JSONObject jsonObj = new JSONObject(str);4 ????????System.out.print(jsonObj + "\n");5 ????????System.out.print(jsonObj.get("code"));6 ????????return jsonObj;7 }
string转json
原文地址:https://www.cnblogs.com/wutantan/p/10240837.html