一般解析json方法自己写起来较为繁琐,利用开源的API可以节省很多事,达到快速的开发。
1) 自己写的代码:
例如:
private void parserJSON(String strJSON)
{
try
{
JSONArray jsonArray = new JSONArray(strJSON);
for (int j = 0; j < jsonArray.length(); j++)
{
JSONObject jsonObject = jsonArray.getJSONObject(j);
String icon1Url = jsonObject.getString("icon1Url");
String fristTile = jsonObject.getString("fristTitle");
String title = jsonObject.getString("title");
String message = jsonObject.getString("message");
String p_w_picpathUrl = jsonObject.getString("p_w_picpathUrl");
String time = jsonObject.getString("time");
String from = jsonObject.getString("from");
mList.add(new HomeData(icon1Url, fri