Fix invalid JSON crashing the server

I accidentally discovered when working with websockets on android that invalid JSON would crash the server, this should handle that issue.