I need to loop through a dictionary and append records to a json object file option.jsonthe code I have is
for K in "${!MYMAP[@]}"; do opt="{ \"OptionName\":\"${K}\", \"Value\":\"${MYMAP[$K]}\" }," echo $opt >> option.jsondone
But this produce option.json as below
{"OptionName": "name","Value": "test"},{"OptionName": "age","Value": "13"}
How do i make the option.json a json object and appending each {} inside the object, so my option.json would look like below
[ {"OptionName": "name","Value": "test" }, {"OptionName": "age","Value": "13" }]