码迷,mamicode.com
首页 > Web开发 > 详细

string转json

时间:2019-01-08 21:00:29      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:maven   dep   nbsp   except   object   \n   pre   ring   div   

首先添加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

标签:maven   dep   nbsp   except   object   \n   pre   ring   div   

原文地址:https://www.cnblogs.com/wutantan/p/10240837.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!