jq从curl返回null

时间:2016-11-02 22:31:08

标签: json docker jq

我在docker容器中运行以下命令:

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

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

1 个答案:

答案 0 :(得分:1)

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

请更改网址

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": {
        "": ""
      }
    }
  ]
}