Artificial intelligent assistant

How to make jq output into a variable here is my code curl random args "link" | jq and gives it gives is { "id": "961438154596153411", "username": "testing", "avatar": "a9000496add364b16af27e2f583a2e1e0f", "discriminator": "1" } how would i save that as a bash variables so i could just do like echo "$id" and it gives me 961438154596153411 or echo "$username" testing Solved Note: a better way of doing this is saving the curl input as json and then using that with jq so you dont have to request stuff multiple times (sorry if this is a dumb question im new to bash and jq)

To extract `961438154596153411` from the json, pipe the file in `jq '.id'`

Example:


$ jq '.id' << EOF
{
"id": "961438154596153411",
"username": "testing",
"avatar": "a9000496add364b16af27e2f583a2e1e0f",
"discriminator": "1"
}
EOF


outputs


"961438154596153411"


If you want it without the quotes, use `-r` for raw data.

All togeather, to put that number into a bash variable, I'd do this:


$ id=$(curl random args "link" | jq -r ".id")
$ echo "$id"
961438154596153411

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy db0e66ce36e61615a284fee3cd43e12a