简体   繁体   中英

Can't Deserialize a Json String to an object containing an object containing an array of objects

I have a JSON Object that is returned from a web service call that looks like this:

{"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":""}

I am attempting to use the following to deserialize the JSON string to an object:

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

The ReturnObject is defined as follows:

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; }
        }
    }

Unfortunately, I get everything except the contents of the individual PeopleResult objects in the List results. The values for all of the properties in the PeopleResult are null. Is there something wrong with the structure or naming of or within my ReturnObject class?

None of the properties in your PeopleResult class are public.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM