Handling JSON encoding and decoding
Passing recieved data to the listen handler properly