我需要在這裏以特定的格式發佈數據的反應是我的格式如何發佈到JSON Server數據庫特定的格式,並得到Android的
{
"Authentication": {
"Username": "*****",
"Password": "****"
},
"File": {
"Orders": [{
"Status":"",
}]
},
"OrderID":16,
"RequestType": 6
}
如何以這種格式發佈的數據,並獲得響應。我試圖以這種方式
HttpClient httpClient = new DefaultHttpClient();
JSONObject object = new JSONObject();
object.put("Username", "******");
object.put("Password", "*******");
JSONObject jsonObject = new JSONObject();
jsonObject.put("Authentication", object);
jsonObject.put("OrderID", data);
jsonObject.put("RequestType", 6);
HttpPost postMethod = new HttpPost("@@@@@@@@@@@@@");
postMethod.setEntity(new StringEntity(jsonObject.toString()));
postMethod.setHeader("Accept", "application/json");
postMethod.setHeader("Content-type", "application/json");
HttpResponse response = httpClient.execute(postMethod);
entity = response.getEntity();
response_value = EntityUtils.toString(entity).toString();
Log.e(TAG, response_value);
我不知道如何添加文件對象,如果你有任何想法幫助我
請在此問題上添加更多描述。 – 2015-02-10 11:04:34