git - 如何在github中创建一个返回json数据的 Gist

标签 git github gist

我遇到了一个返回 JSON 数据的 Gist https://gist.githubusercontent.com/rdsubhas/ed77e9547d989dabe061/raw/6d7775eaacd9beba826e0541ba391c0da3933878/gnc-js-api

我试图创建一个返回 JSON 数据的结果是这样的 https://gist.github.com/vigneshvdm/862ec5a97bbbe2021b79

我怎样才能像第一个那样创建一个链接并让它以 JSON 格式返回数据

最佳答案

问题是 HTTP 响应类型是 text/plain 但您需要 application/json 以便大多数客户端正确处理它。

更新:使用 rawgit.com 我能够让您的测试使用正确的内容类型。

我的测试 Gist : https://gist.githubusercontent.com/anonymous/85dbc2c71023f24c2e26/raw/849848a71a1805a314897f9fe98eb7dc43e2e9b9/gistfile1.json

我的 RawGit 网址: https://rawgit.com/anonymous/85dbc2c71023f24c2e26/raw/849848a71a1805a314897f9fe98eb7dc43e2e9b9/gistfile1.json

使用 HTTP GET,发送:

GET https://rawgit.com/anonymous/85dbc2c71023f24c2e26/raw/849848a71a1805a314897f9fe98eb7dc43e2e9b9/gistfile1.json HTTP/1.1
Accept: application/json
Host: rawgit.com

接收返回:

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 24 Dec 2014 10:57:07 GMT
Content-Type: application/json
Connection: keep-alive
X-Content-Type-Options: nosniff
X-Robots-Tag: none
RawGit-Naughtiness: 0
Access-Control-Allow-Origin: *
ETag: "0250189db62d31523a5cd0da47449eb4"
Cache-Control: max-age=300
Vary: Accept-Encoding
RawGit-Cache-Status: HIT
Content-Length: 104

[{ Name: "Vignesh", Salary: 30000 },{ Name: "Yuvraj", Salary: 90000 },{ Name: "Nithya", Salary: 87000 }]

还有几张截图:

enter image description here

enter image description here

关于git - 如何在github中创建一个返回json数据的 Gist ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27635355/

相关文章:

git - 使用 R 下载、修改、上传 Github Gists

git - 从本地 git 中删除文件,但不从远程中删除文件

git - 让 Git 跟踪重命名和编辑的文件

git - 在 Gerrit 代码审查中更改消息

github - 如何在公共(public) github 存储库上创建后服务 Hook ?

python - 使用 Github API 发布到 Gist

github - 如何从 Gist 中删除文件?

git - 如何在导入期间修复或调查此 AcquiaDevDesktop 错误

git - git 等同于 p 4's "...”模式是什么?

git - 安装后删除 fail2ban.git 是否安全?