JSONArray cities = json.getJSONArray("city");
一個String數組與上面的代碼得到了以下的輸出:JSON字符串在Java
{
"id":"1",
"name":"London"
"country":"United Kingdom"
},
{
"id":"2",
"name":"Madrid"
"country":"Spain"
},
{"id":"3",
"name":"Paris"
"country":"France"
},
{
"id":"3",
"name":"Zurich"
"country":"Switzerland"
}
如何從JSON數組只得到名稱到字符串數組?
例如爲:String[] s ={"London","Madrid","Paris","Zurich"}