I'm writing a Xamarin.Android app and work there with a JSON API, that simply returns an empty string for the data field when it can't find the object in the database. Not a good design, but I can't change it. To check for this eventuality I wrote this short function, which I bind to the LanguageExt.Either object containing the JsonObject and which returns a left value when the data is null.
        private Either<Exception, T> CheckData<T>(T json) where T : JsonObject
        {
            if (json.Data == null)
            {
                return Left<Exception, T>(new KeyNotFoundException());
            }
            else
            {
                return Right(json);
            }
        }
Problem is, it always returns a left value. Trying to change the condition to json.Data.Equals(null) throws a NullPointerException. So far I would guess that I actually have null value in there, but when I step through the program in the debugger it's definitely filled and not null, even when I add a breakpoint right at the if line. I'm honestly at my wits end, how can an object be null, yet not null in the debugger?

 
    