【发布时间】:2019-04-11 18:29:07
【问题描述】:
我必须将这种类型的数据发布到 Json 中。我不想将 cat 转换为字符串。我只想要用双引号括起来的项目的单引号。
{"p02bvsd":"cal_dis","ovpsc7s":{"cat":["'Furniture'", "'Bikes'", "'Others'"]}}
我的 Json
JSONObject jsonobject1 = new JSONObject();
jsonobject.put("p02bvsd", "cal_dis");
jsonobject.put("ovpsc7s", jsonobject1);
jsonobject1.put("cat", hCategory);
这里的 hCategory 是 Hashset。
我想要这样的json
{"p02bvsd":"cal_dis","ovpsc7s":{"cat": ["'Furniture'", "'Bikes'", "'Others'" ]}}
【问题讨论】:
-
你能用相关代码sn-ps分享你现在正在尝试的东西吗?你用什么来转换?
-
@brandonx 问题已更新,请查看
-
请说明您当前获得的输出与期望的输出。
-
好的,但是现在的输出是什么?
-
我认为问题在于
jsonobject1在添加到jsonobject之前正在被修改。