如何发布JSON

时间:2016-06-15 06:15:49

标签: android-json android-async-http

我想以下列格式发布JSON并获得GET响应。

提到JSON:

{
  "success": true,
  "data": {
    "id": "234576"
    "name": "string"
  }
}

1 个答案:

答案 0 :(得分:0)

创建2个json对象,如:

JSONObject parent = new JSONObject();
JSONObject child = new JSONObject();

在子对象中,输入:

parent.put("success", true);
child.put("id", "234567");
child.put("name", "string");
parent.put("data", child);

并使用此父对象简单地调用您的服务。