首頁>Club>
6
回覆列表
  • 1 # 清醒溫柔知進退.

    package com.linyf.demo.fastjson;

    import com.alibaba.fastjson.JSONObject;

    import lombok.AllArgsConstructor;

    import lombok.Data;

    @Data

    @AllArgsConstructor

    public class JsonBean {

    private String name;

    private Integer age;

    public String getJsonString(){

    return JSONObject.toJSONString(this);

    }

    }

    class Test{

    public static void main(String[] args) {

    String jsonString = "{\"name\":\"zhangsan\",\"age\":\"18\"}";

    JsonBean jsonBean = JSONObject.parseObject(jsonString, JsonBean.class);

    System.out.println(jsonBean);

    String jsonString1 = jsonBean.getJsonString();

    System.out.println(jsonString1);

    }

    }

  • 中秋節和大豐收的關聯?
  • 命令與征服3凱恩之怒鍵位指令?