请问如何将这个JOSN数据 转换成DATATABLE 或者list呢。 求有用的代码
{
"users": [{
"id": 1985596337,
"idstr": "1985596337",
"screen_name": "cui琛",
"name": "cui琛",
"province": "21",
"city": "8",
"location": "辽宁 营口",
"description": "你若安好,我便是晴天…",
"url": "",
"profile_image_url": "http://tp2.sinaimg.cn/1985596337/50/5624428541/0",
"profile_url": "xue137938828",
"domain": "xue137938828",
"weihao": "",
"gender": "f",
"followers_count": 236,
"friends_count": 108,
"statuses_count": 329,
"favourites_count": 83,
"created_at": "Wed Feb 23 00:00:00 +0800 2011",
"following": true,
"allow_all_act_msg": false,
"geo_enabled": true,
"verified": false,
"verified_type": 220,
"remark": "",
"status_id": 3428200988563077,
"allow_all_comment": true,
"avatar_large": "http://tp2.sinaimg.cn/1985596337/180/5624428541/0",
"verified_reason": "",
"follow_me": false,
"online_status": 0,
"bi_followers_count": 48,
"lang": "zh-cn"
},
{
"id": 1025887960,
"idstr": "1025887960",
"screen_name": "名字叫LULU丶不寻常",
"name": "名字叫LULU丶不寻常",
"province": "11",
"city": "1000",
"location": "北京",
"description": "繁华散尽人已故,柔情满腔凭谁诉。",
"url": "http://blog.sina.com.cn/nnjay",
"profile_image_url": "http://tp1.sinaimg.cn/1025887960/50/5625981859/0",
"profile_url": "u/1025887960",
"domain": "",
"weihao": "",
"gender": "f",
"followers_count": 214,
"friends_count": 100,
"statuses_count": 423,
"favourites_count": 80,
"created_at": "Mon Aug 09 00:00:00 +0800 2010",
"following": true,
"allow_all_act_msg": true,
"geo_enabled": true,
"verified": false,
"verified_type": 220,
"remark": "",
"status_id": 3428178162408228,
"allow_all_comment": true,
"avatar_large": "http://tp1.sinaimg.cn/1025887960/180/5625981859/0",
"verified_reason": "",
"follow_me": false,
"online_status": 0,
"bi_followers_count": 88,
"lang": "zh-cn"
},
{
"id": 2300721592,
"idstr": "2300721592",
"screen_name": "-心理蔡岳",
"name": "-心理蔡岳",
"province": "44",
"city": "5",
"location": "广东 汕头",
"description": "我注定孤独 就像我注定没人喜欢",
"url": "",
"profile_image_url": "http://tp1.sinaimg.cn/2300721592/50/5627397491/1",
"profile_url": "cycyhe",
"domain": "cycyhe",
"weihao": "",
"gender": "m",
"followers_count": 125,
"friends_count": 156,
"statuses_count": 331,
"favourites_count": 95,
"created_at": "Wed Aug 10 00:00:00 +0800 2011",
"following": true,
"allow_all_act_msg": false,
"geo_enabled": true,
"verified": false,
"verified_type": 200,
"remark": "",
"status_id": 3427884796929383,
"allow_all_comment": true,
"avatar_large": "http://tp1.sinaimg.cn/2300721592/180/5627397491/1",
"verified_reason": "",
"follow_me": true,
"online_status": 0,
"bi_followers_count": 102,
"lang": "zh-cn"
},
{
"id": 1771623354,
"idstr": "1771623354",
"screen_name": "陳瀚彬-阿B",
"name": "陳瀚彬-阿B",
"province": "44",
"city": "1000",
"location": "广东",
"description": "我天生不怕磨练 亦从没怨过雨天",
"url": "http://binbnjie.blog.163.com",
"profile_image_url": "http://tp3.sinaimg.cn/1771623354/50/5627263490/1",
"profile_url": "u/1771623354",
"domain": "",
"weihao": "",
"gender": "m",
"followers_count": 611,
"friends_count": 307,
"statuses_count": 1743,
"favourites_count": 7,
"created_at": "Mon Jul 26 00:00:00 +0800 2010",
"following": true,
"allow_all_act_msg": false,
"geo_enabled": true,
"verified": false,
"verified_type": 220,
"remark": "",
"status_id": 3427926626643177,
"allow_all_comment": true,
"avatar_large": "http://tp3.sinaimg.cn/1771623354/180/5627263490/1",
"verified_reason": "",
"follow_me": true,
"online_status": 0,
"bi_followers_count": 262,
"lang": "zh-tw"
}],
"next_cursor": 50,
"previous_cursor": 0,
"total_number": 1818
}
[解决办法]
http://blog.csdn.net/wyw308/article/details/7398907
这个也许可以
[解决办法]
using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
public class JsonTest
{
public List<RootObject> jsonToList
{
string jsonString = {
"users": [{
"id": 1985596337,
"idstr": "1985596337",
...};
JavaScriptSerializer json = new JavaScriptSerializer();
List<RootObject> list = json.Deserialize(jsonString, typeof(List<RootObject>)) as List<RootObject>;
return list;
}
}
public class User
{
public long id { get; set; }
public string idstr { get; set; }
public string screen_name { get; set; }
public string name { get; set; }
public string province { get; set; }
public string city { get; set; }
public string location { get; set; }
public string description { get; set; }
public string url { get; set; }
public string profile_image_url { get; set; }
public string profile_url { get; set; }
public string domain { get; set; }
public string weihao { get; set; }
public string gender { get; set; }
public int followers_count { get; set; }
public int friends_count { get; set; }
public int statuses_count { get; set; }
public int favourites_count { get; set; }
public string created_at { get; set; }
public bool following { get; set; }
public bool allow_all_act_msg { get; set; }
public bool geo_enabled { get; set; }
public bool verified { get; set; }
public int verified_type { get; set; }
public string remark { get; set; }
public object status_id { get; set; }
public bool allow_all_comment { get; set; }
public string avatar_large { get; set; }
public string verified_reason { get; set; }
public bool follow_me { get; set; }
public int online_status { get; set; }
public int bi_followers_count { get; set; }
public string lang { get; set; }
}
public class Root public List<User> users { get; set; }
public int next_cursor { get; set; }
public int previous_cursor { get; set; }
public int total_number { get; set; }
}
[解决办法]
额,刚才发现第二个对象有点问题,应该是这样的
public class RootObject
{
public List<User> users { get; set; }
public int next_cursor { get; set; }
public int previous_cursor { get; set; }
public int total_number { get; set; }
}