diff --git a/src/iceberg/util/json_util_internal.h b/src/iceberg/util/json_util_internal.h index c525ac90a..81d17b04b 100644 --- a/src/iceberg/util/json_util_internal.h +++ b/src/iceberg/util/json_util_internal.h @@ -57,7 +57,7 @@ Result GetJsonValueImpl(const nlohmann::json& json, std::string_view key) { template Result> GetJsonValueOptional(const nlohmann::json& json, std::string_view key) { - if (!json.contains(key)) { + if (!json.contains(key) || json.at(key).is_null()) { return std::nullopt; } ICEBERG_ASSIGN_OR_RAISE(auto value, GetJsonValueImpl(json, key)); @@ -66,7 +66,7 @@ Result> GetJsonValueOptional(const nlohmann::json& json, template Result GetJsonValue(const nlohmann::json& json, std::string_view key) { - if (!json.contains(key)) { + if (!json.contains(key) || json.at(key).is_null()) { return JsonParseError("Missing '{}' in {}", key, SafeDumpJson(json)); } return GetJsonValueImpl(json, key); @@ -75,7 +75,7 @@ Result GetJsonValue(const nlohmann::json& json, std::string_view key) { template Result GetJsonValueOrDefault(const nlohmann::json& json, std::string_view key, T default_value = T{}) { - if (!json.contains(key)) { + if (!json.contains(key) || json.at(key).is_null()) { return default_value; } return GetJsonValueImpl(json, key);