I am trying to convert a json structure that key1: array of values, key2: array of values ,.... to an array of objects. The size of arrays is same and each object is just aggregate of items at position x in each array. Need help converting this preferably with generic code with jq.
Input
{
"IdentifierName": [
"A",
"B",
"C"
],
"Code": [
5,
8,
19
]
}
Expected Output
[
{
"IdentifierName": "A",
"Code": 5
},
{
"IdentifierName": "B",
"Code": 8
},
{
"IdentifierName": "C",
"Code": 19
}
]
Edit: progress so far:
jq 'to_entries|map(.key) as $keys| (map(.value)|transpose) as $values |$values|map($keys, .)'
The last step is to somehow index with the keys into the values that I am still unable to get right.