jq

Extract "packages" key from skopeo output with jq


I'm trying to extract the list of packages from skopeo inspect output, but this does not seem to work:

❯ skopeo inspect docker://ghcr.io/ublue-os/bluefin-dx:gts | jq '.Labels."dev.hhd.rechunk.info".packages'

The above works without the ".packages" part and the content is:

❯ skopeo inspect docker://ghcr.io/ublue-os/bluefin-dx:gts | jq '.Labels."dev.hhd.rechunk.info"'
"{\"version\": 2, \"uniq\": \"gts-40.20250305\", \"packages\": {\"libgcc\": \"14.2.1-3.fc40\", .....

How can I ask jq to go into this object and extract just the "packages" part?


Solution

  • Use fromjson to parse json text:

    $ skopeo inspect docker://ghcr.io/ublue-os/bluefin-dx:gts | jq '.Labels."dev.hhd.rechunk.info" | fromjson.packages'
    {
      "libgcc": "14.2.1-3.fc40"
    }