0

I have a JSON something like

{
"kubernetes": {
    "container_name": "test",
    "container_hash": "test",
    "host": "host1",
    "docker_id": "faaf",
    "pod_id": "222-44f0-8ff0-87faf2bf1f9c",
    "labels": {
        "job-name": "job-name-1"
    }
},
"taskchain_id": "77d07cfb-484c-4b49-856c-354310ea8f66"
}

I want to have an output like:

77d07cfb-484c-4b49-856c-354310ea8f66 job-name-1

I can get

.kubernetes.labels."job-name"

To get the job-name-1 and .taskchain_id to get the chain ID

Is there anyway to get these both in same command?

Suhas
  • 17
  • 4
  • 1
    Does this answer your question? [Using jq to parse and display multiple fields in a json serially](https://stackoverflow.com/questions/28164849/using-jq-to-parse-and-display-multiple-fields-in-a-json-serially) and [How to concat multiple fields to same line with jq](https://stackoverflow.com/q/56486272/5291015) – Inian May 19 '21 at 08:36
  • :( That was simple. Thanks. Need to learn a lot more – Suhas May 19 '21 at 08:39

1 Answers1

0
 .taskchain_id + " " +.kubernetes.labels."job-name"

https://jqplay.org/s/n7-LguIZtu

Jagadesh
  • 2,104
  • 1
  • 16
  • 28