This is the method I use to encode JSON data to communicate with a server