【发布时间】:2017-05-10 09:55:50
【问题描述】:
我在 ion 库中传递 JSON 数组时遇到了问题。如何发送两个 JSON 数组和离子库中的 JSON 对象。
在下面的代码中,我如何将 json 数组传递到 ion 库中。
JsonObject jsonObject = new JsonObject();
JsonArray keywordTags = new JsonArray();
for (String tagsKeyWord:tags) {
JsonPrimitive jsonPrimitive = new JsonPrimitive(tagsKeyWord);
keywordTags.add(jsonPrimitive);
}
jsonObject.add("tags",keywordTags);
Ion.with(this)
.load("http://database/api/scamer-database")
.setHeader("Authorization", authorization)
.setTimeout(60 * 60 * 1000);
.setMultipartParameter("city_subur",city)
.setMultipartParameter("state",state)
.setMultipartParameter("postalCode",postalCode)
.setMultipartParameter("tags", jsonObject.toString() )
.setMultipartParameter("tactics",tactic)
.withResponse()
.setCallback(new FutureCallback<Response<JsonObject>>() {
@Override
public void onCompleted(Exception e, Response<JsonObject> result) {
}
});
输出是这样的
{
"city_subur": "Homenickside",
"state": "Bartellside",
"postalCode": "46228-0535",
"tags": [
"tag name 1",
"tag name 2",
"Apply Online"
]
"tactic": [
"Called me",
"Asked My Mobile #",
"Asked my account number"
]
}
如何在离子库中添加标签字段?请帮我解决这个问题。
【问题讨论】:
标签: android arrays json android-ion