Per the jq manual
--compact-output / -c:By default, jq pretty-prints JSON output. Using this option will result in more compact output by instead putting each JSON object on a single line.
--compact-output / -c:
--compact-output
-c
By default, jq pretty-prints JSON output. Using this option will result in more compact output by instead putting each JSON object on a single line.
Therefore the following should work:
cat 2.txt | ./jq -c '{(.id): .custom}'