json - curl GET json 文件:输出文件具有附加字符串“文本”和特殊字符,如“\”
问题描述
也许有人可以通过curl请求支持我吗?我正在调用 Bitbucket (v 1.0) 的 REST API 以通过 curl 传输获取 json 文件。调用如下所示:
curl -k -s -X GET -H "Authorization: Bearer xyxyxyz" -H "Content-Type: application/json" \
"https://code.somecompany.corp/bitbucket/rest/api"/1.0/projects/<projectname>/repos/davinci-reviewer-list/browse/mapfile.json --output mapfile.json
输出应该与 mapfile.json 的原始内容完全相同:
{
"repos": [
{
"reponame": "account-opening-svc",
"rev_list": "BE"
},
{
"reponame": "alertmanager-config",
"rev_list": "DEVOPS"
},
{
"reponame": "antivirus-lambda",
"rev_list": "BE"
}
]
}
但是当我打开或 cat mapfile.json 时,字符串 'text' 和字符串 'lines' 已添加到每一行以及特殊字符:
{
"lines": [
{
"text": "{"
},
{
"text": " \"repos\": ["
},
{
"text": " {"
},
{
"text": " \"reponame\": \"account-opening-svc\","
},
{
"text": " \"rev_list\": \"BE\""
},
{
"text": " },"
},
{
"text": " {"
},
{
"text": " \"reponame\": \"alertmanager-config\","
},
{
"text": " \"rev_list\": \"DEVOPS\""
},
{
"text": " },"
},
{
"text": " {"
},
{
"text": " \"reponame\": \"antivirus-lambda\","
},
{
"text": " \"rev_list\": \"BE\""
},
{
"text": " },"
}...
],
"start": 0,
"size": 340,
"isLastPage": true
}
我怎样才能得到原始的 json 内容?提前谢谢了!!!
解决方案
问题已解决 - url 仅指向 Bitbucket 的 api,但需要指向原始数据的链接。就我而言,它看起来像:
/rest/api/1.0/projects/<projectname>/repos/reviewer-list/raw/mapfile.json?at=refs%2Fheads%2Fmaster
推荐阅读
- cmd - 列出 cmd 中不包含特定字符串的文件
- ruby-on-rails - 忽略哈希中的两个参数
- r - 组内的组 ID
- sql - 我想获得有条件的当日销售报告总和
- mongodb - how to use document fields in query in mongodb
- php - 尝试从表中删除数据,直到用户单击删除才知道 ID。SQL & PHP
- apache-spark - CSV文件读取火花1.6
- jmeter - 用于将文件上传到休息端点的 JMeter 测试脚本
- haskell - Haskell 组函数/第一个元素总是丢失
- mysql - 在 mysql 中向字段添加 mysql 唯一约束