【发布时间】:2016-10-05 15:02:55
【问题描述】:
String strJson="{
\"Employee\" :[
{
\"id\":\"01\",
\"name\":\"Gopal Varma\",
\"salary\":\"500000\"
},
{
\"id\":\"02\",
\"name\":\"Sairamkrishna\",
\"salary\":\"500000\"
},
{
\"id\":\"03\",
\"name\":\"Sathish kallakuri\",
\"salary\":\"600000\"
}
]
}";
try {
JSONObject jsonObject = new JSONObject(strJson);
JSONArray jsonArray1=jsonObject.optJSONArray("Employee");
JSONArray jsonArray2=jsonObject.getJSONArray("Employee");
} catch (JSONException e) {
e.printStackTrace();
}
在上面的示例中,optJSONArray("Employee") 和 getJSONArray("Employee") 都返回 JSONArray 有什么区别?
【问题讨论】:
标签: android