【发布时间】:2014-05-07 22:48:58
【问题描述】:
我有这样的答案:
{
"url": "https://api.github.com/gists/47d8d5c3e80bc1568bda",
"forks_url": "https://api.github.com/gists/47d8d5c3e80bc1568bda/forks",
"commits_url": "https://api.github.com/gists/47d8d5c3e80bc1568bda/commits",
"id": "47d8d5c3e80bc1568bda",
"git_pull_url": "https://gist.github.com/47d8d5c3e80bc1568bda.git",
"git_push_url": "https://gist.github.com/47d8d5c3e80bc1568bda.git",
"html_url": "https://gist.github.com/47d8d5c3e80bc1568bda",
"files": {
"fileWhatever": {
"filename": "fileWhatever",
"type": "text/plain",
"language": null,
"raw_url": "https://gist.githubusercontent.com/test/47d8d5c3e80bc1568bda/raw/21aefad8f2f7aea0556360ff3a40a557b793e330/fileWhatever",
"size": 19,
"truncated": false,
"content": "this is the content"
}
}
....
问题是我想取“内容”的价值。我可以这样做:
data.files.fileWhatever.content
但我不应该知道文件的名称,所以“fileWhatever”可以是任何东西。如何跳转一级获取任意文件的内容?
我正在用 javascript 做这个
谢谢
【问题讨论】:
标签: javascript json github get