0

I am using bash to run an AWS command which returns

"{\"username\":\"adamro\",\"password\":\"temppassword\",\"engine\":\"postgres\",\"host\":\"hostapp1\",\"port\":5432,\"dbname\":\"dbprod\",\"dbClusterIdentifier\":\"backend\",\"schema\":\"public\"}"

How can I parse certain keys from this such as the username, password and hostname?

  • This is double-encoded JSON. See [How to parse a JSON string with jq (or other alternatives?)](https://stackoverflow.com/questions/35154684/how-to-parse-a-json-string-with-jq-or-other-alternatives) -- in particular, you want the answers using `fromjson`; `jq -r 'fromjson | .username'`, for example, will return the username. – Charles Duffy Jun 14 '22 at 23:43
  • Use the JSON parsing tool `jq`. – Andy Lester Jun 14 '22 at 23:43

0 Answers0