我如何提取下面的json並將其保存在arraylist中。提取並保存Json到Arraylist Android
{
"trains": {
"train": [
{
"@id": 1000000103,
"@version": 1,
"@status": "active",
"@name": "dffffff",
"@description": "ffffff half of the nineteenth century.",
"@city": "fff",
"@phone": "+230 595-1454",
"@email": "[email protected]",
"@website": "www4u",
"@latitude": -5.2882,
"@longitude": 3.499,
"@defaultLocale": "",
"@holes": 48,
"@par": 72,
"@slope": 0,
"@distance": 5.005273,
"circuits": {
"circuit": []
},
"localizations": {
"localization": []
}
},
{
"@id": 1000000105,
"@version": 1,
"@status": "active",
"@name": " xClub",
"@description": "",
"@city": " xlet",
"@phone": "+44465\t",
"@email": "",
"@website": "wweffl.com",
"@latitude": -2.040318,
"@longitude": 54548,
"@defaultLocale": "",
"@holes": 18,
"@par": 32,
"@slope": 0,
"@distance": 2441673,
"circuits": {
"circuit": []
},
"localizations": {
"localization": []
}
}
]
}
}
我的工作
try {
jobj_trouve_train = new JSONObject(reponse_trouve_train);
String jsonobj = jobj_trouve_golf.getString("trains");
//String jsonobj1 = jobj_trouve_golf.getString("train");
//jobj_trouve_train = new JSONObject(reponse_trouve_train);
//jsonArray = jobj_trouve_golf.getJSONArray("trains");
//jsonArray= new JSONArray(jsonobj);
//System.out.println("jsonArray "+jsonArray);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
謝謝你這一行JSONArray jsonobj1 = jsonobj.getJSONArray(「train」);是解決方案aligato – Dimitri