Added a status code argument to writeJSON.