在Javascript中,我无法解析这个 JSON ,它有一个"#"在里面。我想获得一个图片网址。
我的尝试是: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"
},
答案 0 :(得分:2)
尝试
tracks.track[0].image[0]['#text']
请注意,我使用正则表达式添加引号来解析字符串
PS:你写了tracks.track[0].image[0].#track
,但我假设#text
,因为我在JSON中看不到任何#track
...如果你的意思是{ {1}},然后更改为适当的*