Check for data before converting to JSON