If I have a json string in a bass script, then how can I convert it to an array?
{"name": "foo", "id": "123"} {"name": "bar", "id": "456"}
Do I want to be prompted on the w / name, and she will tell me which ID (in one variable) I need to use
something like
Raise your poison: 1) Foo 2) times #?
If I select 1, then id There is a better way to read data in an Associated Array For - here, using for parsing. Given this, you Then you can handle your menu: 123
goes to the variable X, and if I select 2, then id 456 <
declared - a data = () while the IFS = read -r id name; Data is named [$ id] = $ & lt; & Lt; (Jq -r '@text' \ (. Id) \ (.nim) "'<
echo "Choose your poison:" "$ {! Data [=]} "for ID in; name = $ {data [$ id]} printf '% d)% s \ n'" $ id "" $ name "read -p ''? 'Selection resonant' user Selected $ {data [$ selection]} "
No comments:
Post a Comment