2016-11-02 93 views
0

我跑码头工人,容器内的以下命令无效:JQ返回从卷曲

curl 'https://demo.cachethq.io/API/v1/components?name=Blog' | tac | tac | jq '.' 

,但我得到空输出(卷曲进度条后),运行 没有最终JQ命令给出正确的JSON 。 任何帮助,将不胜感激 (该tac是停止在jq之前结束卷曲输出)

+0

仔细检查您所使用的URL。正如你的问题所写,URL返回一个HTML页面,指出找不到资源。我检查了文档的密码,并且URL以小写形式列出(您有“.../API/...”,而不是“.../api/...”)。我尝试了小写版本,并按预期工作,包括通过管道连接到jq。 –

+0

是的,今天我被迫输入我的电话并输入错误 - Rao是正确的。但是我仍然不能从jq中跳出来,但是tac的输出仍然很好 –

+0

好了,终于知道这里出了什么问题......我从npm安装了jq。原来这是一个完全不同的包,与jquery有关。一旦我从brew中安装,它完美运行。愚蠢的名字重叠...... :( –

回答

1

这是一个微不足道的错误。

请从更改URL

curl 'https://demo.cachethq.io/API/v1/components?name=Blog' | tac | tac | jq '.' 

要:

curl 'https://demo.cachethq.io/api/v1/components?name=Blog' | tac | tac | jq '.' 

输出:

% Total % Received % Xferd Average Speed Time Time  Time Current 
           Dload Upload Total Spent Left Speed 
100 426 0 426 0  0 176  0 --:--:-- 0:00:02 --:--:-- 176 
{ 
    "meta": { 
    "pagination": { 
     "total": 1, 
     "count": 1, 
     "per_page": 20, 
     "current_page": 1, 
     "total_pages": 1, 
     "links": { 
     "next_page": null, 
     "previous_page": null 
     } 
    } 
    }, 
    "data": [ 
    { 
     "id": 4, 
     "name": "Blog", 
     "description": "The Alt Three Blog.", 
     "link": "https://blog.alt-three.com", 
     "status": 1, 
     "order": 0, 
     "group_id": 2, 
     "created_at": "2016-11-03 01:30:01", 
     "updated_at": "2016-11-03 01:30:01", 
     "deleted_at": null, 
     "enabled": true, 
     "status_name": "Operational", 
     "tags": { 
     "": "" 
     } 
    } 
    ] 
}