Problem Deserializing

Sep 11, 2010 at 3:13 PM
Edited Sep 11, 2010 at 3:14 PM

I'll let the code speak for itself. In the Update() method, the JSON is deserialized to a PatientInputModel, but the property "records" in obj is null and not populated. Should be simple, but I'm new to this library. Thanks.

    {"records":{"ExternalRef":"xx","SocSecNb":"xx","DateOfBirth":"1970-01-01","LastName":"xx","MiddleName":"xx","FirstName":"xx","Suffix":"xx","id":11}}

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Update()
    {
            string body;
            using (var reader = new StreamReader(Request.InputStream))
                body = reader.ReadToEnd();

            PatientInputModel obj = JsonConvert.DeserializeObject<PatientInputModel>(body);

            ...
    }

    public class PatientInputModel
    {
       PatientDirectoryRecord records;
     }

    [JsonObject(MemberSerialization.OptOut)]
    public class PatientDirectoryRecord
    {
        public int id { get; set; }
        public string ExternalRef { get; set; }
        public string SocSecNb { get; set; }
        [JsonConverter(typeof(IsoDateTimeConverter))]
        public DateTime DateOfBirth { get; set; }
        public string LastName { get; set; }
        public string MiddleName { get; set; }
        public string FirstName { get; set; }
        public string Suffix { get; set; }
        public bool IsDeleted { get; set; }

        public PatientDirectoryRecord() { }
    }