cast json payload to Buffer and set length