【发布时间】:2014-06-24 10:27:54
【问题描述】:
我正在使用 servicestack 将我从 Web 服务获得的 JSON 反序列化为对象。 该过程有效(无例外),但我无法访问反序列化对象中的类。
我的代码这样称呼:
LoginResultModel result = new LoginResultModel
{
Avatars = new Avatars(),
Country = new Country(),
RootObject = new RootObject()
};
result = client.Post<LoginResultModel>(URL, postData);
一旦我得到结果(LoginResultModel 类型),我就无法访问其中的任何内容! Intellisense 无济于事——“结果”。不要显示与该类相关的任何内容。
我猜我在层次结构上做错了什么? (很奇怪,因为没有抛出异常)。我做错了什么?
反序列化形式的 JSON(使用 json2Csharp):
public class LoginResultModel
{
/// <summary>
/// IsLogedIn method
/// </summary>
public Country Country { get; set; }
public Avatars Avatars { get; set; }
public RootObject RootObject { get; set; }
}
public class Country
{
public string Name { get; set; }
public string A2 { get; set; }
public int Code { get; set; }
public int PhonePrefix { get; set; }
}
public class Avatars
{
public string Small { get; set; }
public string Medium { get; set; }
public string Large { get; set; }
}
public class RootObject
{
public int CID { get; set; }
public string Username { get; set; }
public Country Country { get; set; }
public string URL { get; set; }
public int AffiliateID { get; set; }
public Avatars Avatars { get; set; }
public bool IsLoggedIn { get; set; }
public bool AllowCommunity { get; set; }
public string Token { get; set; }
public int TokenExpirationInMinutes { get; set; }
public bool IsKYCRequired { get; set; }
}
【问题讨论】:
标签: c# servicestack json-deserialization