Explicitly convert undefined to null for res.json