I am trying to read the json file and store the keys as bash variable and the values as variable value. For instance here is my test.json:
{
"Day":'0',
"num":'85',
"Qtr":"[20183, 20184, 20191, 20192]",
"pSize":"75"
}
I need to store the variables like this in a bash file:
$Day=0
$num=85
$Qtr=[20183, 20184, 20191, 20192]
$psize=75
I found a way to extract the value using jq, but I am unable to store the key as variable in bash
-bash-4.2$ Qtr=`jq .Qtr test.json`
-bash-4.2$ echo $Qtr
"[20183, 20184, 20191, 20192]"
Could someone please provide a snippet as to how to loop through a json file and store the key as variables and values as values?
Thank you in advance