{ // json object node "formules": [ // json array formules { // json object "formule": "Linear Motion", // string "url": "qp1" }你在做什么
Context context = null; // context is null try { String jsonLocation = AssetJSonFile("formules.json", context);因此更改为
try { String jsonLocation = AssetJSonFile("formules.json", CatList.this);解析
我相信你是从assests文件夹中获取字符串的。
try{String jsonLocation = AssetJSonFile("formules.json", context);JSonObject jsonobject = new JSonObject(jsonLocation);JSonArray jarray = (JSONArray) jsonobject.getJSonArray("formules");for(int i=0;i<jarray.length();i++){JSonObject jb =(JSONObject) jarray.get(i);String formula = jb.getString("formule");String url = jb.getString("url");}} catch (IOException e) { e.printStackTrace();} catch (JSonException e) { e.printStackTrace();}


