[lib] output should always be JSON followed by \r\n