1.首先依赖 版本的话 一般1.2.58以上都可以
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
</dependency>
2.常用的几个api
String content = question.getContent(); JSONObject jsonObject = JSONObject.parseObject(content); //json转 jsonObject ,可以拿到里面的key value String titleImg = jsonObject.getString("titleImg"); //通过key获取value if (titleImg != null && titleImg != "") { int titleImgType = FileType.wtnlFileType(titleImg); jsonObject.put("titleImgType",titleImgType); //往jsonObject里put元素
question.setContent(jsonObject.toJSONString()); } //jsonObject对象转string
标签:FastJson,入门,1.2,jsonObject,question,titleImg,String,titleImgType,阿里巴巴 From: https://www.cnblogs.com/onlyzhangmeng/p/17023269.html