I have the following JSON data:
{\"id\":\"111\",\"case\":\"Y\",\"custom\":{\"speech invoked\":\"no\",\"input method\":\"hard\",\"session ID\":\"420\"}}
Using jq, you can use this filter:
with_entries(select(.key != "custom")) + .custom | to_entries | map(.key), map(.value) | @csv
Just note that written this way, the "custom" properties will always be written in the end, no matter what order the properties are in.