A more elegant way to dump some code. Handles json and plain text.