Deserialization of complex JSON Object?

Jun 16, 2013 at 1:29 PM
Edited Jun 16, 2013 at 6:15 PM
Hello All,

I have a complex JSON response that looks like this:
{
"response":
{
    "result":
    {
        "Contacts":
        {
            "row":
            [
                {
                    "no":"1",
                    "FL":
                    [
                        {
                            "content":"555555000000123456",
                            "val":"CONTACTID"
                        },
                        {
                            "content":"555555000000012345",
                            "val":"SMOWNERID"
                        },
                        {
                            "content":"John Doe",
                            "val":"Contact Owner"
                        },
                        {
                            "content":"Pete",
                            "val":"First Name"
                        },
                        {
                            "content":"Smith",
                            "val":"Last Name"
                        },
                        {
                            "content":"pete@mail.com",
                            "val":"Email"
                        },
                        {
                            "content":"5555551000000012346",
                            "val":"SMCREATORID"
                        },
                        {
                            "content":"Jane Doe",
                            "val":"Created By"
                        },
                        {
                            "content":"555555000000012347",
                            "val":"MODIFIEDBY"
                        },
                        {
                            "content":"Doris Doe",
                            "val":"Modified By"
                        },
                        {
                            "content":"2013-06-14 17:24:10",
                            "val":"Created Time"
                        },
                        {
                            "content":"2013-06-14 17:24:10",
                            "val":"Modified Time"
                        },
                        {
                            "content":"2013-06-14 17:28:05",
                            "val":"Last Activity Time"
                        }
                    ]
                },
                {
                    ...
                }
            ]
        }
    },
    "uri":"/crm/private/json/Contacts/getRecords"
}
And I have created a class that looks like this:
public class Contact
{
    [JsonProperty(PropertyName = "CONTACTID")]
    public string ContactID { get; set; }
    [JsonProperty(PropertyName = "SMOWNERID")]
    public string OwnerID { get; set; }
    [JsonProperty(PropertyName = "Contact Owner")]
    public string ContactOwner { get; set; }
    [JsonProperty(PropertyName = "First Name")]
    public string FirstName { get; set; }
    [JsonProperty(PropertyName = "Last Name")]
    public string LasName { get; set; }
    [JsonProperty(PropertyName = "Email")]
    public string Email { get; set; }
    [JsonProperty(PropertyName = "SMCREATORID")]
    public string CreatorID { get; set; }
    [JsonProperty(PropertyName = "Created By")]
    public string CreatedBy { get; set; }
    [JsonProperty(PropertyName = "MODIFIEDBY")]
    public string ModifiedByID { get; set; }
    [JsonProperty(PropertyName = "Modified By")]
    public string ModifiedBy { get; set; }
    [JsonProperty(PropertyName = "Created Time")]
    public DateTime CreatedTime { get; set; }
    [JsonProperty(PropertyName = "Modified Time")]
    public DateTime ModifiedTime { get; set; }
    [JsonProperty(PropertyName = "Last Activity Time")]
    public DateTime LastActivityTime { get; set; }
}
I have tried to deserialize this object like this, without any luck:
var deserializedObjects = JsonConvert.DeserializeObject<List<Contact>>(jsonString);
Can anyone provide a suggestion on what the easiest way is to do this? What I am trying to do is to get a Generic List of Contacts out of this.

Thanks,
Pete
Jun 18, 2013 at 2:03 PM
Does anyone have an answer for this? It's been sitting unanswered for a few days, and I really need to move forward with this project.

Thanks,
Pete
Jun 18, 2013 at 6:12 PM
psoheil wrote:
Does anyone have an answer for this? It's been sitting unanswered for a few days, and I really need to move forward with this project.

Thanks,
Pete
There has been very few responses to questions asked here, as far as I can tell. I'd post this to StackOverflow if I were you.
Jun 18, 2013 at 6:28 PM
I did that already. But I am not getting any responses there either:

http://stackoverflow.com/questions/17126323/parsing-a-complex-json-result-with-c-sharp

Is this such an impossible question that no one knows the answer to?

Pete
Jun 21, 2013 at 1:31 PM
Post your sample project which does the above deserialization. It makes the job of the person trying to help easier.