Convert dates properly to JSON.