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
  • 741,623
  • 53
  • 500
  • 612
AmazingDayToday
  • 3,724
  • 14
  • 35
  • 67

1 Answers1

0

Using jq:

jq .username <<<"$output"
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441