Add proper null check for JSON object