无法将Json String反序列化为包含包含对象数组的对象的对象

时间:2012-04-05 22:29:59

标签: c# json web-services javascriptserializer

我有一个从Web服务调用返回的JSON对象,如下所示:

{"responseData":{"results":[{
    "mothraId":null,
    "studentId":null,
    "bannerPIdM":null,
    "externalId":null,
    "dFirstName":null,
    "dFullName":null,
    "dLastName":null,
    "dMiddleName":null,
    "modifyDate":"2012-02-24 06:24:33",
    "oFirstName":"Joe",
    "oFullName":"Joe R Smith",
    "oLastName":"Smith",
    "oMiddleName":"R",
    "iamId":"999999999",
    "ppsId":"999999999",
    "oSuffix":null,
    "dSuffix":null,
    "isEmployee":null,
    "isHSEmployee":null,
    "isFaculty":"N",
    "isStudent":"N",
    "isStaff":"N",
    "isExternal":"N",
    "privacyCode":null}]},
"responseStatus":0,
"responseDetails":""}

我正在尝试使用以下命令将JSON字符串反序列化为对象:

ReturnObject allInOne = js.Deserialize<ReturnObject>(jsonResponse);

ReturnObject的定义如下:

public class ReturnObject
{
    public String responseDetails { get; set; }
    public String responseCode { get; set; }
    public ResponseData responseData { get; set; }

    public class ResponseData
    {
        public List<PeopleResult> results { get; set; }

        public class PeopleResult{

            String iamId { get; set; }
            String mothraId { get; set; }
            String ppsId { get; set; }
            String studentId { get; set; }
            String bannerPIdM { get; set; }
            String externalId { get; set; }
            String oFirstName { get; set; }
            String oMiddleName { get; set; }
            String oLastName { get; set; }
            String oFullName { get; set; }
            String oSuffix { get; set; }
            String dFirstName { get; set; }
            String dMiddleName { get; set; }
            String dLastName { get; set; }
            String dSuffix { get; set; }
            String dFullName { get; set; }
            String isEmployee { get; set; }
            String isHSEmployee { get; set; }
            String isFaculty { get; set; }
            String isStudent { get; set; }
            String isStaff { get; set; }
            String isExternal { get; set; }
            String privacyCode { get; set; }
            String modifyDate { get; set; }
        }
    }

不幸的是,除了List结果中各个PeopleResult对象的内容之外,我得到了所有内容。 PeopleResult中所有属性的值均为null。我的ReturnObject类的结构或命名是否有问题?

1 个答案:

答案 0 :(得分:1)

您的PeopleResult类中的所有属性都不公开。