fastjson中toString与toJSONString的差别

时间:2024-03-01 09:28:18

查看JSONObject源码:

 @Override
    public String toString() {
        return toJSONString();
    }

    public String toJSONString() {
        SerializeWriter out = new SerializeWriter();
        try {
            new JSONSerializer(out).write(this);
            return out.toString();
        } finally {
            out.close();
        }
    }

其实toString()方法内部还是调用了toJSONString()方法