解析不适用于json Android 解析不起作用json Android
{
"group_name":"МБА-14",
"days":[
{
"weekday":1,
"lessons":[
{
"subject":"Научно-исследовательский семинар",
"type":0,
"time_start":"17:10",
"time_end":"18:30",
"time_number":6,
"parity":1
}
]
}
]
}
我需要在工作日获得价值。这是我的代码:
JSONObject jsonObject=new JSONObject(str);
JSONObject jsonObject1=jsonObject.getJSONObject("weekday");
Log.e("aaaa", jsonObject1.toString() );
答案 0 :(得分:2)
JSONArray days = jsonObject.getJSONArray("days");
JSONObject oneDay = days.getJSONObject(0);
int weekday = oneDay.getInt("weekday");
答案 1 :(得分:0)
如果你的“str”变量包含这个, 然后解析像
JSONObject jsonObject=new JSONObject(str);
JSONArray jArray = jsonObject.getJSONArray("days");
String weekday = (jArray .getJSONObject(0)).getString("weekday");