私はJsonを作成していますが、正しいフォーマットを作成していません。ユーザーの最初のプロパティと最後のプロパティ項目のみが提供され、完全なjsonは提供されません..事前に感謝します..私のコードは
JSONObject json = new JSONObject();
try {
JSONObject subJson = new JSONObject();
//JSONArray jsonArray = new JSONArray();
subJson.put("saleManId", LogIn.UserId);
subJson.put("customerId", LogIn.CustomerId);
json.put("User", subJson);
for (int i = 0; i < LogIn.subValues.length; i++) {
JSONObject subSubObj = new JSONObject();
for (int j = 0; j < LogIn.subValues[i].length; j++) {
if (LogIn.subValues[i][j] > 0) {
JSONObject item = new JSONObject();
item.put("itemID", LogIn.subIds[i][j]);
item.put("qty", LogIn.subValues[i][j]);
subSubObj.put("item", item);
}
}
if(subSubObj.length()>0)
{
json.put("orderDetail", subSubObj);
Log.d("json", json.toString());
}
}
Log.d("jsonnnnnnnnnnnnnnnnnnnnnnnnnnnnn", json.toString());
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
配列には30から35のアイテムがありますが、これしかありません
{"orderDetail":{"item":{"qty":1,"itemID":"60"}},"User":{"customerId":"460","saleManId":"1"}}