encode data into json before sending the payload