package com.wing.ihome.cloud.system.modular.system.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
/**
* <p>
*
* </p>
*
* @author: heluwei
* @Date: 2020/4/29 8:23
*/
public class TestJSON {
public static void main(String[] args) {
//使用链式创建对象。
Test build = Test.builder().result("success").msg("success").build();
System.out.println(build);
//Java对象转String
String s = JSON.toJSONString(build);
System.out.println(s);
//字符串转 JSONObject对象
JSONObject jsonObject = JSONObject.parseObject(s);
System.out.println(jsonObject);
//JSONObject转 Javabean对象
Test test = jsonObject.toJavaObject(Test.class);
System.out.println(test);
}
}