Is there any way to create nested json in bash.
{
"t1": {
"k1": "v1",
"k2": "v2"
},
"t2": {
"k1": "v1",
"k2": "v2"
}
}
I have 2 variable having space separated values.
var1="aa bb cc dd" -- which gives t1,t2 etc in the sample json
var2="ee ff gg hh" -- which gives k1,k2 etc in the sample json
Upon iterating the variables i should derive the values of t's, k's and v's in the json. Below is the loop which i'm thinking to have. However can be changed based on the suggestion.
for i in var1;
do
-----
-----
for j in var2;
do
-----
'json creation'
done
done