我的字符串包含JSON如何从android中的json字符串创建JSONObject和JSON ARRAy?
result=[{"USER_ID":83,"PROJECT_BY_DETAILS":"An adaptation of a nursery rhyme into a dramatic film"},{"USER_ID":88,"PROJECT_BY_DETAILS":"Test - over ye mountain blue "}]
如何从这个字符串创建的JSONObject和JSONarray
我用这个代码
JSONObject json =new JSONObject(result);
//Get the element that holds the earthquakes (JSONArray)
JSONArray earthquakes = json.getJSONArray("");
我得到错误
Error parsing data org.json.JSONException: Value [{"USER_ID":83,"PRO
CAn你举个例子。 – sandeep
这就是你所需要的。我解释一下。我唯一想念的是Gson的实例化。像Gson gson = new Gson(); –
我编辑了答案,检查出来。 –