我应该如何解析这个json?
{"label":"KLM/AirFrance"}
我试试
jsonObject.getString("label")
但是有一个错误:
at org.json.JSON.typeMismatch
有任何想法吗?谢谢。
代码:
ArrayList<Gate> gates = new ArrayList<Gate>();
JSONArray jGates = object.getJSONArray("gates_info");
int gatesLength = jGates.length();
for (int i=0; i<gatesLength; i++) {
Gate gate = new Gate();
JSONObject jGate = jGates.getJSONObject(i);
gate.setId(jGate.getInt("id"));
gate.setLabel(jGate.getString("label"));
gate.setCurrency_code(jGate.getString("currency_code"));
gates.add(gate);
}
部分回复:
"gates_info":[{"id":48,"label":"KLM/AirFrance","payment_methods":
["card"],"currency_code":"usd","is_airline":true},
{"id":1,"label":"Nabortu","payment_methods":
["bank","yandex_money","web_money","terminal","card","svyaznoy","euroset"],
"currency_code":"rub","is_airline":false},
{"id":3,"label":"anywayanyday.com","payment_methods":
["card","euroset","svyaznoy"],"currency_code":"rub","is_airline":false},
{"id":7,"label":"Ozon.travel","payment_methods":
["cash","yandex_money","web_money","terminal","card","elexnet","contact","euroset"],
"currency_code":"rub","is_airline":false},
{"id":8,"label":"tickets.ru","payment_methods":
["card","web_money"],"currency_code":"rub","is_airline":false}