Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/201.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 解析不起作用_Android_Json - Fatal编程技术网

Android 解析不起作用

Android 解析不起作用,android,json,Android,Json,解析不起作用 解析不起作用 { "group_name":"МБА-14", "days":[ { "weekday":1, "lessons":[ { "subject":"Научно-исследовательский семинар", "type":0, "time_start":"17:10", "time_end":"18:30", "time_number":6, "parity":1 } ] } ] } 我需要在工作日获取值。这是我的代码: JSONObject

解析不起作用 解析不起作用

{
"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() );
如果您的“str”变量包含此项, 然后像这样解析

JSONObject jsonObject=new JSONObject(str);
JSONArray jArray = jsonObject.getJSONArray("days");
String weekday = (jArray .getJSONObject(0)).getString("weekday");

你得到了什么输出?或者它崩溃了?不是,我收到了“组名”:“МБА-14”,“天”:[{“工作日”:1,“课程”:[{“主题”:“18:30”,“时间编号”:6,“工作日”是json中的字符串。所以使用
string weekDay=jsonObject.getString(“weekDay”);
@Kunu。我也这样做了。不工作。jsonObject jsonObject=new jsonObject(str);Log.e(“aaaa”,jsonObject.getString(“weekDay”));请先发布您的确切json。您能用Java编写吗?.I Android.JSONArray days=jsonObject.getJSONArray(“days”);jsonObject无法解析符号“jsonObject”@droonkkisd您忘记了第一行:
jsonObject jsonObject=new jsonObject(str);
@Ircover。您可以得到类似“subject”的值.JSONObject JSONObject=new JSONObject(str);Log.e(“asdas”,JSONObject.get(“subject”).toString();???????通过继续我的代码,在
String
need
oneDay.getString(“课程”)中获取课程
,但最好调用
getJSONArray
进行进一步的工作。@Ircover.Ok:)。另一个问题。您如何知道数组的大小?
JSONObject jsonObject=new JSONObject(str);
JSONArray jArray = jsonObject.getJSONArray("days");
String weekday = (jArray .getJSONObject(0)).getString("weekday");