Artificial intelligent assistant

replace tab with space input json: [ { "name": "cust1", "grp": [ { "id": "46", "name": "BA2" }, { "id": "36", "name": "GA1" }, { "id": "47", "name": "NA1" }, { "id": "37", "name": "TR3" }, { "id": "38", "name": "TS1" } ] } ] how to get .grp[] names separated with space on @tsv output? $ jq -r '.[]|[.name, (.grp//[{"name":"-"}]|.[]|" ",.name)]|@tsv' test_inp cust1 BA2 GA1 NA1 TR3 TS1 expected output for above sample: cust[TAB]BA2[SPACE]GA1[SPACE]NA1[SPACE]TR3[SPACE]TS1

**`jq`** approach:


jq -r '.[] | [.name, (.grp | map(.name) | join(" "))] | @tsv' input.json


The output:


cust1 BA2 GA1 NA1 TR3 TS1

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 39471507b07a36030b9a8b54e943a055