簡體   English   中英

使用jq從JSON提取URL

[英]Extract URL from JSON using jq

我有以下可用的json輸出,我需要使用jq處理器提取href的值,這是https URL。

我嘗試使用

jq -r .links.urn:vodafoneid:follow.hrefs

但是,這行不通嗎?

JSON輸出:

{  
   "links":{  
      "urn:somedomainid:follow":{  
         "href":"https://abc.somedomain.com/ula/login?service=IDGW&channel=WEB&usecaseid=a0b51311-d14b-4733-9e6b-ba5f5deec05f&opco=DE&nonce=89e31cde-fecc-41e1-91d6-1f9f84f9c136&acr_values=explicit&scopes=phone_number&returnUrl=https%3A%2F%2Fidgw.somedomain.com%2Fauthorize%23state%3Da0b51311-d14b-4733-9e6b-ba5f5deec05f",
         "type":"text/html"
      }
   },
   "context":"FOLLOW"
}

您嘗試使用vodafoneid的字段名中有明顯的錯字不是somedomainid 但總的來說,以訪問具有特殊字符,如字段:在他們的名字,做如下領域的適當引用。

jq --raw-output '.links."urn:somedomainid:follow".href'

jqplay.org-URL

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM