【发布时间】:2014-06-18 08:52:18
【问题描述】:
这应该是 JSON 输出:
{
"ph_immunizations_attributes": [
{"immunization_id": 1},
{"immunization_id": 2}
]
}
我将如何在我的 Android 代码中翻译它以发布到我的 Rails 服务器中
这是代码:
List<NameValuePair> immunizatioValuePairs = new ArrayList();
JSONObject jObj = new JSONObject();
JSONObject main = new JSONObject();
JSONArray jA = new JSONArray();
jObj.put("immmunization_id", 1);
jA.put(jObj);
main.put("ph_immunizations_attributes", jA);
immunizatioValuePairs.add(new BasicNameValuePair("ph_immunizations_attributes", main.toString()));
httppost.setEntity(new UrlEncodedFormEntity(immunizatioValuePairs));
【问题讨论】:
标签: android ruby-on-rails arrays json object