use default value in fetchers::PublicKey json deserialization

This commit is contained in:
HaeNoe 2024-04-16 13:48:58 +02:00
parent c73172e986
commit 943a877a6a
No known key found for this signature in database

View File

@ -419,9 +419,13 @@ namespace nlohmann {
using namespace nix; using namespace nix;
fetchers::PublicKey adl_serializer<fetchers::PublicKey>::from_json(const json & json) { fetchers::PublicKey adl_serializer<fetchers::PublicKey>::from_json(const json & json) {
auto type = optionalValueAt(json, "type").value_or("ssh-ed25519"); fetchers::PublicKey res = { };
auto key = valueAt(json, "key"); if (auto type = optionalValueAt(json, "type"))
return fetchers::PublicKey { getString(type), getString(key) }; res.type = getString(*type);
res.key = getString(valueAt(json, "key"));
return res;
} }
void adl_serializer<fetchers::PublicKey>::to_json(json & json, fetchers::PublicKey p) { void adl_serializer<fetchers::PublicKey>::to_json(json & json, fetchers::PublicKey p) {