More JSON encoding error handling.