Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 612

How to remove double-quotes and \ in jq output without making it single line in bash?

$
0
0

I have the following json output

{"secrets": [    ["{","  \"name\": \"testSecret\",","  \"vault-apikey\": \"kv\",","  \"vault-value\": \"sabrinaTest\"","}"    ]  ]}

But I need the output to be a little cleaner and look like this:

{"secrets": [    [        {"name" : "testSecret","vault-apikey" : "kv","vault-value" : "sabrinaTest"        }    ]  ]}

These are the commands that I'm currently running to get this output:

TEST_SECRET_JSON=$(hcp vault-secrets secrets open testSecret --format=json)SECRETS_INFO=$(echo $TEST_SECRET_JSON | jq -r '{"name": .name, "vault-apikey": .type, "vault-value": .static_version.value}')jq -n --arg value "${SECRETS_INFO}" '{ secrets : [ $value | split("\n") ] }'>> secret.json

I have tried other variations, but none have produced the desired results.


Viewing all articles
Browse latest Browse all 612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>