Added null pointer verification when generating JSONs