Come posso creare un JSON con questo formato in Android: Poiché l'API che passerò analizzerà JsonArray quindi l'oggetto. O sarebbe giusto se solo per passare un oggetto JSON? Dal momento che dovrò solo inserire 1 transazione per chiamata di servizio.Android- crea JSON Array e JSON Object
{
"student": [
{
"id": 1,
"name": "John Doe",
"year": "1st",
"curriculum": "Arts",
"birthday": 3/3/1995
},
{
"id": 2,
"name": "Michael West",
"year": "2nd",
"curriculum": "Economic",
"birthday": 4/4/1994
}
]
}
Quello che so è solo il JSONObject. Come questo.
JSONObject obj = new JSONObject();
try {
obj.put("id", "3");
obj.put("name", "NAME OF STUDENT");
obj.put("year", "3rd");
obj.put("curriculum", "Arts");
obj.put("birthday", "5/5/1993");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Qualsiasi idea. Grazie
qual è l'isseu? – Blackbelt
[link di riferimento] (http://chintankhetiya.wordpress.com/2013/05/27/83/) –
inserendo JSONObject in un JSONArray per ottenere il formato pubblicato. – sftdev