Android 如何从json数组中提取值
您好,我是android开发的新手,我想从json数组中提取值,请您指导我 这是我的jsonAndroid 如何从json数组中提取值,android,Android,您好,我是android开发的新手,我想从json数组中提取值,请您指导我 这是我的json [ { "Id": "c0f3310b-5ec2-4af0", "UserId": "fd83ca17-41f5-472a", "ProfileId": "100006690", "ProfileType": "facebook", "ProfileDate": "/Date(1380894956000)/",
[
{
"Id": "c0f3310b-5ec2-4af0",
"UserId": "fd83ca17-41f5-472a",
"ProfileId": "100006690",
"ProfileType": "facebook",
"ProfileDate": "/Date(1380894956000)/",
"ProfileStatus": 1
},
{
"Id": "6954433d-b78e-47b6",
"UserId": "fd83ca17-41f5-8efe",
"ProfileId": "100004492",
"ProfileDate": "/Date(1380894685000)/",
"ProfileStatus": 1,
"ProfileType": "facebook"
}
]
谢谢你喜欢下面的编码
JSONArray jObject = new JSONArray(jsoninputstring);
for (int i = 0; i < jObject.length(); i++) {
JSONObject obj = jObject.getJSONObject(i);
String name= obj.getString("Id");
String email= obj.getString("UserId");
String image= obj.getString("ProfileId");
}
JSONArray作业对象=新的JSONArray(jsoninputstring);
对于(int i=0;i
下面是JSON解析的教程
创建新的JSONArray对象并对其进行迭代
JSONArray arr = new JSONArray(jsonString);
for(int i=0;i<arr.length;i++){
JSONObject obj = arr.getJSONObject(i);
// read data from obj using obj.getString method.
}
JSONArray arr=新的JSONArray(jsonString);
对于(int i=0;iJSONArray categories=responseData.getJSONArray(“categories”);//您的JSON数组
对于(int i=0;i
我强烈建议您查看JacksonParser…您可以从下载jar文件,您可以很容易地找到许多使用jar的示例。这是将json解析为对象的最简单、最快速的方法。JSONArray JSONArray=new JSONArray(yourResponseString);
JSONArray jsonArray = new JSONArray(yourResponseString);
for(int i=0;i<jsonArray.length();i++){
JSONObject dataObject=dataArray.getJSONObject(i);
String ID=dataObject.getString("Id");
String UserID=dataObject.getString("UserId");
String ProfileID = jsonObject.getString("ProfileId");
..
}
对于(int i=0;i请尝试搜索像这样的现有线程,如果找不到任何线程,请在此处发布。因为我认为已经有很多关于此线程的线程可以帮助您解决问题。-链接可以作为注释发布。发布一些details@Raghunandan是的
JSONArray jsonArray = new JSONArray(yourResponseString);
for(int i=0;i<jsonArray.length();i++){
JSONObject dataObject=dataArray.getJSONObject(i);
String ID=dataObject.getString("Id");
String UserID=dataObject.getString("UserId");
String ProfileID = jsonObject.getString("ProfileId");
..
}