1.导入json包
import com.alibaba.fastjson.JSONObject;
2.对象转换为json字符串
public String toJson() { return JSONObject.toJSONString(this); }
3.json字符串转换为对象
JSONObject json= JSONObject.parseObject(jsonStr, JSONObject .class);
1.导入json包
import com.alibaba.fastjson.JSONObject;
2.对象转换为json字符串
public String toJson() { return JSONObject.toJSONString(this); }
3.json字符串转换为对象
JSONObject json= JSONObject.parseObject(jsonStr, JSONObject .class);