0

How to make a bash array from this JSON using jq

[
  {
    "username": "abc@com",
    "name": "ABC",
    "given_name": "DotCom",
    "password": "iDWtCEKiA#!@345",
    "email": "abc@com"
  },
  {
    "username": "def@com",
    "name": "DEF",
    "given_name": "DotCom",
    "password": "iDWtCEKiA#!@345",
    "email": "def@com"
  }
]

I need to get all object values with a loop (3000 objects) so I will be like this :

index(0) username: abc.com , name: ABC index(1) username: def.com , name: DEF

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
  • We encourage questioners to show what they have tried so far to solve the problem themselves. – Cyrus Feb 11 '23 at 10:08
  • I suppose you want the result to be an indexed Bash array (as it features indices). But how should the items be formatted/encoded? As JSON objects (just like in the original JSON input)? Then you are missing out some curly braces in your desired result (apart from the ususal code formatting). Or are you looking for a multidimensional Bash array? Then the answer is simple: Bash does not support them, and you'd need some sort of a workaround (ideally tailored to your overall post-processing goal, which you haven't disclosed yet). – pmf Feb 11 '23 at 10:20

0 Answers0