这里使用的是阿里的 fastjson 包
1、引入jar包
<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.9</version> </dependency>
2、代码
import com.alibaba.fastjson.JSONObject; public class Test{ public static void main( String[] args ){ String res = "{"result": "success","msg": "登陆成功"}" JSONObject jsonObject = JSONObject.parseObject(res); System.out.println(jsonObject.getString("msg")); } }
原文链接:https://blog.csdn.net/qq_39415129/article/details/100117657