CORE-4757: added some more checks for null values and instances of JSONNull