-1

I've tried a ton of combos on this handy tool here: https://jqplay.org But I can't seem to get the piece I need. Here's my JSON:

{
  "data": {
    "translations": [
      {
        "translatedText": "El rápido zorro marrón saltó sobre el perro perezoso."
      }
    ]
  }
}

I'm trying to get just this part "El rápido zorro marrón saltó sobre el perro perezoso." without quotes.

The closest I got was with this:

.data.translations 

(but this fails to get what I'm looking for) Any help would be great, thanks.

I got flagged for a duplicate question, but this isn't using Javascript.

Geek Grid
  • 207
  • 6
  • 17
  • 2
    `.data.translations[0].translatedText` and make sure you check the `Raw Output` checkbox (translates to the `--raw-output` or `-r` flags if using in the command line). – Gavin Aug 03 '17 at 17:55
  • Possible duplicate of [Access / process (nested) objects, arrays or JSON](https://stackoverflow.com/questions/11922383/access-process-nested-objects-arrays-or-json) – JJJ Aug 03 '17 at 17:58
  • @JJJ, no... jq isn't javascript. – Jeff Mercado Aug 03 '17 at 18:12
  • @Gavin thanks! Worked perfectly. – Geek Grid Aug 03 '17 at 19:06

1 Answers1

3

Consider also:

$ jq -r '.data.translations[].translatedText' input.json
El rápido zorro marrón saltó sobre el perro perezoso.

or even:

jq -r '.data.translations[][]' input.json
El rápido zorro marrón saltó sobre el perro perezoso.

Which is appropriate will of course depend on the detailed requirements.

peak
  • 105,803
  • 17
  • 152
  • 177