I want to transform the following input with jq:
{
"root":[
{
"field1":"field1value1",
"field2":"field2value2",
"field3Array":[
{
"prop1":"prop1_value1"
}
]
},
{
"field1":"field1value3",
"field2":"field2value4",
"field3Array":[
{
"prop1":"prop1_value3"
},
{
"prop1":"prop1_value4"
}
]
}
]
}
Output should be:
[
{
"field1": "field1value1",
"field2": "field2value2",
"field3Array": "prop1_value1"
},
{
"field1": "field1value3",
"field2": "field2value4",
"field3Array": "prop1_value3,prop1_value4"
}
]
I use this jq filter so far:
[.root[] | {field1, field2, field3Array: .field3Array[].prop1}]
but I don't know how to join the array property "prop1" to a comma-delimited string "prop1_value3,prop1_value4".