0

どこでデシリアライズしたかわかりませんか?

C# JSON クラス:

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

私のJSON文字列:

[{
"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": ...

そして逆シリアル化コード:

 AllProjectsList = JsonConvert.DeserializeObject<AllProjects>(response.Content) as AllProjects;
4

2 に答える 2

1

問題はデシリアライゼーション行にあります。これを簡単に行うことができます:

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

それが役に立てば幸い !

于 2013-08-20T07:38:12.223 に答える