Skip to content

Commit 6703e3e

Browse files
committed
update
1 parent 8906ff3 commit 6703e3e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/iceberg/util/json_util_internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Result<T> GetJsonValueImpl(const nlohmann::json& json, std::string_view key) {
5757
template <typename T>
5858
Result<std::optional<T>> GetJsonValueOptional(const nlohmann::json& json,
5959
std::string_view key) {
60-
if (!json.contains(key)) {
60+
if (!json.contains(key) || json.at(key).is_null()) {
6161
return std::nullopt;
6262
}
6363
ICEBERG_ASSIGN_OR_RAISE(auto value, GetJsonValueImpl<T>(json, key));
@@ -66,7 +66,7 @@ Result<std::optional<T>> GetJsonValueOptional(const nlohmann::json& json,
6666

6767
template <typename T>
6868
Result<T> GetJsonValue(const nlohmann::json& json, std::string_view key) {
69-
if (!json.contains(key)) {
69+
if (!json.contains(key) || json.at(key).is_null()) {
7070
return JsonParseError("Missing '{}' in {}", key, SafeDumpJson(json));
7171
}
7272
return GetJsonValueImpl<T>(json, key);
@@ -75,7 +75,7 @@ Result<T> GetJsonValue(const nlohmann::json& json, std::string_view key) {
7575
template <typename T>
7676
Result<T> GetJsonValueOrDefault(const nlohmann::json& json, std::string_view key,
7777
T default_value = T{}) {
78-
if (!json.contains(key)) {
78+
if (!json.contains(key) || json.at(key).is_null()) {
7979
return default_value;
8080
}
8181
return GetJsonValueImpl<T>(json, key);

0 commit comments

Comments
 (0)