在 Javascript 中,我无法解析这个JSON里面有一个“#”。我想获取图像 URL。
我的尝试是:tracks.track[0].image[0].#track
#把我搞砸了......
{
tracks: {
track: [
{
name: "Stressed Out",
duration: "0",
playcount: "1516304",
listeners: "186543",
mbid: "",
url: "http://www.last.fm/music/Twenty+One+Pilots/_/Stressed+Out",
streamable: {
#text: "0",
fulltrack: "0"
},
artist: {
name: "Twenty One Pilots",
mbid: "a6c6897a-7415-4f8d-b5a5-3a5e05f3be67",
url: "http://www.last.fm/music/Twenty+One+Pilots"
},
image: [
{
#text: "http://img2-ak.lst.fm/i/u/34s/5c3d2c588ae38b7ff192f6b4cec71170.png",
size: "small"
},
{
#text: "http://img2-ak.lst.fm/i/u/64s/5c3d2c588ae38b7ff192f6b4cec71170.png",
size: "medium"
},
Try
tracks.track[0].image[0]['#text']
在 JSFiddle 中查看 https://jsfiddle.net/awy91ezn/1/
Note that I'm adding the quotes using a regex to parse the string
PS:你写的tracks.track[0].image[0].#track
但我假设#text
,因为我没有看到任何#track
在 JSON 中...如果你真的想说#track
,然后进行适当的更改*
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)