每次有名字中带有“&”符号的艺术家出现时,我会在我的标签“R3HAB VINAI”而不是“R3HAB & VINAI”上获得整个字符串,因为它是对最终用户更有用。奇怪的是,“&”符号显示在曲目名称中很好。也许有人可以告诉我我做错了什么。从user.getRecentTracks艺术家缺少字符串中的字符
last.fm JSON API数据
{
recenttracks:{
track:[
{
artist:{
#text:"R3HAB & VINAI",
mbid:"eb0fbe2c-6eb7-40bc-900b-3e056c158125"
},
name:"HOW WE PARTY",
streamable:"0",
mbid:"b410da12-f308-4e2f-af88-19c69312e450",
album:{
#text:"",
mbid:""
},
url:"https://www.last.fm/music/R3HAB+&+VINAI/_/HOW+WE+PARTY",
image:[
{
#text:"",
size:"small"
},
{
#text:"",
size:"medium"
},
{
#text:"",
size:"large"
},
{
#text:"",
size:"extralarge"
}
],
@attr:{
nowplaying:"true"
}
},
{
artist:{
#text:"Alan Walker",
mbid:""
},
name:"Sing me to Sleep",
streamable:"0",
mbid:"",
album:{
#text:"",
mbid:""
},
url:"https://www.last.fm/music/Alan+Walker/_/Sing+me+to+Sleep",
image:[
{
#text:"",
size:"small"
},
{
#text:"",
size:"medium"
},
{
#text:"",
size:"large"
},
{
#text:"",
size:"extralarge"
}
],
date:{
uts:"1501613749",
#text:"01 Aug 2017, 18:55"
}
}
],
@attr:{
user:"SomeName",
page:"1",
perPage:"1",
totalPages:"8676",
total:"8676"
}
}
}
C#类上市
public class Rootobject
{
public Recenttracks recenttracks { get; set; }
}
public class Recenttracks
{
public Track[] track { get; set; }
public Attr attr { get; set; }
}
public class Attr
{
public string user { get; set; }
public string page { get; set; }
public string perPage { get; set; }
public string totalPages { get; set; }
public string total { get; set; }
}
public class Track
{
public Artist artist { get; set; }
public string name { get; set; }
public string streamable { get; set; }
public string mbid { get; set; }
public Album album { get; set; }
public string url { get; set; }
public Image[] image { get; set; }
public Attr1 attr { get; set; }
public Date date { get; set; }
}
public class Artist
{
[JsonProperty("#text")]
public string text { get; set; }
public string mbid { get; set; }
}
public class Album
{
public string text { get; set; }
public string mbid { get; set; }
}
public class Attr1
{
public string nowplaying { get; set; }
}
public class Date
{
public string uts { get; set; }
public string text { get; set; }
}
public class Image
{
public string text { get; set; }
public string size { get; set; }
}
WHE你是否显示这些标签?在网页上?的WinForms?两者都需要转义,但以不同的方式 –
像WinForm标签一样?我相信你需要将'&'加倍。所以用'&&'替换'&'。 https://stackoverflow.com/questions/4325094/enter-symbol-into-a-text-label-in-windows-forms – TyCobb
取决于你如何显示字符串。我们需要知道它是一个winform,xml,html等,根据你的情况'&'的解释是不同的。 –