gpt4 book ai didi

c# - Json对象从YouTube返回重复字段

转载 作者:行者123 更新时间:2023-12-03 06:33:43 25 4
gpt4 key购买 nike

我有以下来自YouTube链接的Json C#代码,该代码具有两个具有相同名称的属性,即author,author2和author内部名称-name uri(我将其更改为Uris,因为它是关键字)在调用url时,它将返回所有内容但不是作者,它对作者显示为空,请帮助我解决此问题

这是我的源代码,

[DataContract]   
public class Title
{
[DataMember (Name="$t")]
public string title { get; set; }
}
[DataContract]
public class Name2
{
[DataMember(Name = "$t")]
public string authorname { get; set; }
}
[DataContract]
public class Uri2
{
[DataMember(Name = "$t")]
public string channelurl { get; set; }
}

public class Author2
{
public Name2 name { get; set; }
public Uri2 uri { get; set; }
}
[DataContract]
public class YtChannelId
{
[DataMember (Name="$t")]
public string channelid { get; set; }
}
[DataContract]
public class MediaThumbnail
{
[DataMember(Name = "url")]
public string imgurl { get; set; }
}
[DataContract]
public class MediaGroup
{
[DataMember (Name="media$thumbnail")]
public List<MediaThumbnail> media_thumbnail { get; set; }
}
[DataContract]
public class FeAEntry
{
public List<Author2> author { get; set; }
[DataMember (Name="yt$channelId")]
public YtChannelId channelId { get; set; }
public Title title { get; set; }
[DataMember (Name="media$group")]
public MediaGroup media_group { get; set; }
}

public class FeAFeed
{
public List<FeAEntry> entry { get; set; }
}
public class Name
{
[DataMember (Name="$t")]
public string t { get; set; }
}

public class Uris
{
[DataMember (Name="$t")]
public string t { get; set; }
}
public class Author
{
public Name name { get; set; }
public Uris uri { get; set; }
}
public class FeARootObject
{
public FeAFeed feed { get; set; }
public List<Author> author { get; set; }
}

问候,

西瓦

最佳答案

您没有将[DataMember]属性分配给author属性。 WCF仅序列化DataMembers。

您的Author2类也缺少[DataContract]属性。

另请:http://msdn.microsoft.com/en-us/library/ms733127.aspx

关于c# - Json对象从YouTube返回重复字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17327295/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com