0

sorry for simplicity, but I am new to bash.

I am curling a link that returns me json file:

$output=$(curl localhost:9000/user/1)

This returns me:

{"userId":"1", "username":"sam"}

How can echo username sam?

These didn't work:

echo $output.userId
echo $output["userId"]
Barmar
  • 669,327
  • 51
  • 454
  • 560
AmazingDayToday
  • 2,984
  • 12
  • 29
  • 58

1 Answers1

0

Using jq:

jq .username <<<"$output"
Charles Duffy
  • 257,635
  • 38
  • 339
  • 400