setup response JSON, with some simple error checking