如何将具有空值的密钥放在net.sf.json.JSONObject中? [英] How can I put key with null value in net.sf.json.JSONObject?
本文介绍了如何将具有空值的密钥放在net.sf.json.JSONObject中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 net.sf.json.JSONObject .如果我尝试使用
我该怎么办?
解决方案
json.put("myKeyu",JSONObject.NULL);
更多详细信息put method.
Is there any way to keep my key as it is in my object even my value is null?
for ex.
JSONObject json = new JSONObject(); json.put("myKey",null);
Then my output is : {}
But I want
output : {"myKey",""}
How can I do?
解决方案
json.put("myKeyu",JSONObject.NULL);
More details here.
这篇关于如何将具有空值的密钥放在net.sf.json.JSONObject中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文