convert post and payloads to json before sending to server