java 对象转json json转对象

旧城等待, 2023-10-04 13:54 114阅读 0赞

java 对象转json json转对象

  1. import com.alibaba.fastjson.JSON;
  2. /**
  3. *
  4. * @title: fastjson
  5. * @author: wll
  6. * @since: 2021-5-19 13:47:40
  7. */
  8. public class TestJson {
  9. public static void main(String[] args) {
  10. String Json="{}";
  11. //json转对象
  12. Xxxx parseObject = JSON.parseObject(Json, Xxxx.class);
  13. //对象转json
  14. String jsonString = JSON.toJSONString(parseObject);
  15. }
  16. }

发表评论

表情:
评论列表 (有 0 条评论,114人围观)

还没有评论,来说两句吧...

相关阅读

    相关 json对象java对象

    项目里需要把json对象转换成java对象,还挺费劲的搜了搜,于是自己记下来,以后方便使用。 第一种方法,使用 JSON-lib 。 第二种方法,使用 JACKSON。