[英]How to get JSON data from attributes that start with # or @ in Typescript
嘗試使用,
album[0]["@attr"]
album[0]["artist"]["#text"]
嘿,對於 JSON,您可以通過其中的屬性名稱使用獲取詳細信息,並且對於以 @ 或 # 開頭的全天候相同,它將是相同的。
請參閱下面的代碼以獲取指定鍵的值:
樣品 JSON:
{
"weeklyalbumchart": {
"album": [
{
"artist": {
"mbid": "data",
"#text": "Flying Lotus"
},
"mbid": "data",
"url": "",
"name": "",
"@attr": {
"rank": "1"
},
"playcount": "21"
},
{
"artist": {
"mbid": "data",
"#text": "Flying Lotus"
},
"mbid": "data",
"url": "",
"name": "",
"@attr": {
"rank": "1"
},
"playcount": "21"
}
]
}
}
讀取 JSON:
@attr ===> json["weeklyalbumchart"]["album"][0]["@attr"]
#text ===> json["weeklyalbumchart"]["album"][0]["artist"]["#text"]
希望這能幫助你理解它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.