简体   繁体   中英

How to parse input with jq

I have the list of docker images in json, for example:

{
  "name": "chart1",
  "version": "1.1.0",
  "appVersion": "1.1.0",
  "dependencies": [
  {
    "name": "name1",
    "version": "10000.1.wew2133"
   },
   {
    "name": "name2",
    "version": "10001.1.wew2133"
   }
  ]
}

I need to convert this to list:

name1:10000.1.wew2133
name2:10001.1.wew2133

How can I do this?

Use join(":") :

jq --raw-output '.dependencies[] | join(":")'
name1:10000.1.wew2133
name2:10001.1.wew2133

JQPlay demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM