json 拼装空list、object

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
 
public class FastJsonArrayTest {
    public static void main(String[] args) {
        JSONObject jo = new JSONObject();
        jo.put("name", null);
        jo.put("age", 123);
        jo.put("list", new JSONArray());
        jo.put("obj", new JSONObject());
        System.out.println(jo.toJSONString());
    }
}

打印结果:

{"age":123,"list":[],"obj":{}}

原文链接:https://blog.csdn.net/tengdazhang770960436/article/details/48930661

猜你喜欢

转载自www.cnblogs.com/lvchengda/p/12604076.html
今日推荐