const std::function()

in src/iceberg/json_internal.cc [316:339]


    const std::function<Result<T>(const nlohmann::json&)>& from_json =
        [](const nlohmann::json& json) -> Result<T> {
      static_assert(std::is_same_v<T, std::string>, "T must be std::string");
      try {
        return json.get<std::string>();
      } catch (const std::exception& ex) {
        return JsonParseError("Cannot parse {} to a string value: {}", json.dump(),
                              ex.what());
      }
    }) {
  std::unordered_map<std::string, T> map{};
  if (json.contains(key)) {
    ICEBERG_ASSIGN_OR_RAISE(auto map_json, GetJsonValue<nlohmann::json>(json, key));
    if (!map_json.is_object()) {
      return JsonParseError("Cannot parse '{}' from non-object: {}", key,
                            map_json.dump());
    }
    for (const auto& [key, value] : map_json.items()) {
      ICEBERG_ASSIGN_OR_RAISE(auto entry, from_json(value));
      map[key] = std::move(entry);
    }
  }
  return map;
}