Allow passing in a default() function to the json encoder.