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;
fetchers::PublicKey adl_serializer<fetchers::PublicKey>::from_json(const json & json) {
auto type = optionalValueAt(json, "type").value_or("ssh-ed25519");
auto key = valueAt(json, "key");
return fetchers::PublicKey { getString(type), getString(key) };
fetchers::PublicKey res = { };
if (auto type = optionalValueAt(json, "type"))
res.type = getString(*type);
res.key = getString(valueAt(json, "key"));
return res;
}
void adl_serializer<fetchers::PublicKey>::to_json(json & json, fetchers::PublicKey p) {