"{\"Dict\":{\"User\":{\"userDepartID\":99,\"userName\":\"admin\"}},\"Timeout\":20}"
建立好類的屬性對應你的json字符串,然後JsonConvert.DeserializeObject反序列化就行了,大概如下
public class cUser{
public int userDepartID;
public string userName;
}
public class cDict{
public cUser User;
public int Timeout;
}
public class cUserInfo{
public cDict Dict;
}
cUserInfo UserInfo = (cUserInfo)Newtonsoft.Json.JavaScriptConvert.DeserializeObject("json字符串", typeof(cUserInfo));
JSON.NET使用示例