Fixed bug when receiving json

When a server receives a json message of the socket it panics. This pull request fixes the bug.