Abstract JSON send

This also appends a newline to JSON to be sent. This makes socket
buffering more straightforward for clients.
Merge pull request #14 from zachallaun/json-newlines

Abstract JSON send