查看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()方法