【发布时间】:2018-04-03 13:33:24
【问题描述】:
final String gene = "[" + "\"" + "xxx" + "\"" + "]";
String jsonString = new JSONObject()
.put("type", "Clinical")
.put("tests", gene).toString();
在我的 jsonString 中添加了转义字符 \
{"tests":"[\"PR20065.01\"]","type":"Clinical"}
我要发帖
{"tests":["PR20065.01"],"type":"Clinical"}
*我是java新手
【问题讨论】:
-
为什么要预先格式化文本?
JSONObject将为您格式化。如果您想将一组值添加到tests键,那么您应该使用JSONArray对象 -
您应该为此使用 JSONArray:请阅读stackoverflow.com/questions/12142238/…
标签: java