[英]How do I deserialize json to c# model if the json object has a name starting with an int
我正在尝试更新JIRA API插件,因为除了当前的局限性之外,我还需要做更多的事情。 问题是Jira有一个avatarUrl字段,其名称类似于48x48
32x32
我正在使用deserializer.Deserialize deserializer.Deserialize<CommentsContainer>(response)
以将json反序列化为对象。 有什么想法可以捕获这些信息吗? 我需要在页面上显示这些头像。 谢谢你的帮助。
我建议使用JSON.NET,这对于在Jira API上处理棘手的Json是非常有用的自由。 我用这种方法为您辩护
实体:
public class ProjectDescription : BaseEntity
{
public int Id { get; set; }
public string Key { get; set; }
public string Name { get; set; }
[JsonProperty("avatarUrls")]
public AvatarUrls AvatarUrls { get; set; }
}
public class AvatarUrls
{
[JsonProperty("32x32")]
public string Size32 { get; set; }
[JsonProperty("48x48")]
public string Size48 { get; set; }
}
然后反序列化对Enity的响应:
var projects = JsonConvert.DeserializeObject<List<ProjectDescription>>(response);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.