0

Cant figure out where i deserialized wrong?

C# JSON classes:

AllProjects [] AllProjectsList;

public class AllProjects
{
    public Project [] Projects { get; set; }
}
public class Project
{
    [JsonProperty("self")]
    public string self { get; set; }
    [JsonProperty("id")]
    public string id { get; set; }
    [JsonProperty("key")]
    public string key { get; set; }
    [JsonProperty("name")]
    public string name { get; set; }
    [JsonProperty("avatarUrls")]
    public Dictionary<string, string> Result { get; set; }
}

My JSON string:

[{
"self":"https://test.test.com/rest/api/2/project/AAAVOA",
"id":"11211",   
"key":"AAAVOA",
"name":"AAA VOA",
"avatarUrls":   
    {
        "16x16":"https://test.test.com/secure/projectavatar?size=small&pid=11211&avatarId=10281",
        "48x48":"https://test.test.com/secure/projectavatar?pid=11211&avatarId=10281"
    }
},
{
"self": ...

And deserialization code:

 AllProjectsList = JsonConvert.DeserializeObject<AllProjects>(response.Content) as AllProjects;
1
  • 1
    Nor can we because you haven't told us what error you're getting :) Please update the question to add the specific exception you're getting. Commented Aug 20, 2013 at 7:36

2 Answers 2

1

The problem is on your deserialization line. You can simply do this :

List<Project> projects = JsonConvert.DeserializeObject<List<Project>>(response.Content);

Hope it helps !

Sign up to request clarification or add additional context in comments.

Comments

0

You may check json2csharp to get an idea of what your classes should look like.

1 Comment

Thanks, checked myself. I forgot 1 row =)))

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.