在我的服务中,我有这个类定义:
class SomeItem {
private String item;
private String[] tags;
//gettter/setters
}
如何将标记字段(这是一个JSON数组)发布到服务?
{ "item": "notebook", "tags": [{"type":"region","code":"nam", "name":"nam"},
{"type":"author", "code":"BBB", "name":"Alex"}]}
答案 0 :(得分:0)
ArrayList<JSONObject> arrayList = new ArrayList<JSONObject>();
JSONObject postedJSON = new JSONObject();
try {
objJSON.put("key", "value");
// add key value for json formating
} catch (JSONException e) {
e.printStackTrace();
}
arrayList.add(postedJSON);
String variable = arrayList.toString();