Bootstrap FreeKB - jq - raw output to eliminate double quotes
jq - raw output to eliminate double quotes

Updated:   |  jq articles

Let's say my.json contains the following, where there are a few keys.

{
  "fruits": [
    "apple",
    "banana",
    "grapes"
  ],
  "veggies": [
    "onion",
    "pepper",
    "carrot"
  ],
  "grains": [
    "rice",
    "couscous",
    "quinoa"
  ]
}

 

Index numbers can be used to return a specific key. Notice in this example that the output is wrapped in double quotes.

]$ jq 'keys[0]' my.json
"fruits"

 

The -r or --raw-output flag can be used so that the output does not include double quotes.

~]$ jq --raw-output 'keys[0]' my.json
fruits



Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter be99ba in the box below so that we can be sure you are a human.