jq '.FiberSwitchPorts[]| { "port": .PortName?, "conn": .ConnectionFiberlines?[] , "mlayer": .Fiberlines?[]} ' | jq -s ' group_by(.port) | .[]| { port : .[0].port, conn: [ .[].conn],mlayer: [.[].mlayer] } '