I've never used jq to generate JSON, only parse. So this is untraveled territory for me.
I found jq & bash: make JSON array from variable, which gets me closer to what I'm seeking. However, I've yet to determine how to dynamically create key names for the structure I'm seeking.
The structure I'm seeking looks something like this:
{
"eth0":
{
"key1": "value1",
"key2": "value2",
"key3": "value3"
},
"eth3":
{
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
}
derived from csv:
iface,key1,key2,key3
eth0,value1,value2,value3
eth3,value1,value2,value3
The problem I've been having is the dynamic generation of the keys in the JSON from the CSV. I haven't been able to find jq's ability to do that. I'm using jq 1.5.
Am I spinning my wheels on this?
EDIT - possible answer
Currently investigating this cookbook answer:
https://github.com/stedolan/jq/wiki/Cookbook#convert-a-csv-file-with-headers-to-json