Java对象转JSONObject(互转)
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
Gson g = new Gson();
Notice notice = g.fromJson(s, Notice.class); //json字符串转java对象 需要的是Gson
/*这里需要强转一下 默认是Object
JSONObject jsonStu = (JSONObject) JSONObject.toJSON(notice); //对象转JSONObject 需要的是上边的包
还没有评论,来说两句吧...