我遇到了一个返回JSON数据的要点 https://gist.githubusercontent.com/rdsubhas/ed77e9547d989dabe061/raw/6d7775eaacd9beba826e0541ba391c0da3933878/gnc-js-api
我试图创建一个返回JSON数据,最终像这样 https://gist.github.com/vigneshvdm/862ec5a97bbbe2021b79
如何创建第一个链接并使其以JSON格式返回数据
Ada*_*her 14
问题是HTTP响应类型,text/plain
但application/json
大多数客户端都需要正确处理它.
更新:使用rawgit.com我能够使用正确的内容类型进行测试.
我的测试要点: 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
Run Code Online (Sandbox Code Playgroud)
收回:
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 }]
Run Code Online (Sandbox Code Playgroud)
还有一些截图:
raw
.点击它,你有任何你的纯文本版本.需要注意的一点是它出现了json数据,但标题显示 - Content-Type:text/plain
您可以使用https://rawgit.com/来修改标题.
归档时间: |
|
查看次数: |
7888 次 |
最近记录: |