Refactor. We now have a common way of handling incoming JSON messages
no matter where they come from (TCP or stdin).