【发布时间】:2018-05-13 01:55:58
【问题描述】:
我在 liferay 6.2 中使用 com.liferay.portal.kernel.json.JSONObject,我想将空值存储在这种类型的对象中,如下所述
`JSONObject jsonObject = JSONFactoryUtil.createJSONObject();`
`jsonObject.put("name","varun")`
`jsonObject.put("address",null)`
和 org.json.JSONObject 一样,我们可以通过 JSONObject.NULL 设置 null
有什么方法可以在 liferay JSONObject 中设置 null 吗?
【问题讨论】:
-
为什么不能同时使用
org.json.JSONObject.NULL来代替com.liferay.portal.kernel.json.JSONObject.put?我知道,这很麻烦,但至少它有效。您可以为其引入自己的常量以规避包引用。