如何解析这个json?

时间:2015-06-27 13:01:35

标签: android json

    String jsondata="{\"studentResult\":[{\"sem1\" :[{\"subname\":\"TOC\",\"subcode\":\"1009\",\"subcredit\":\"6\",\"subgrade\":\"AB\"},
    {\"subname\":\"DS\",\"subcode\":\"10090\",\"subcredit\":\"5\",\"subgrade\":\"BB\"},
    {\"subname\":\"TOC\",\"subcode\":\"1009\",\"subcredit\":\"6\",\"subgrade\":\"AB\"}]},{\"sem2\":
   [{\"subname\":\"AAS\",\"subcode\":\"111009\",\"subcredit\":\"6\",\"subgrade\":\"AB\"},
{\"subname\":\"AE\",\"subcode\":\"103309\",\"subcredit\":\"6\",\"subgrade\":\"DD\"}] }]}";

1 个答案:

答案 0 :(得分:0)

在这里试试:

String json = "{\"key\":\"value\",\"key\":\"value\"}";

try {
    JSONObject obj = new JSONObject(json);
    Log.i("My App", "JSONObject in String: " + obj.toString());
} catch (JSONException e) {
    e.printStackTrace();
}