mirror of
https://github.com/NixOS/nix.git
synced 2025-12-13 20:41:04 +01:00
update fetchers::PublicKey json (de)serialization
This commit is contained in:
parent
ff4c286e80
commit
e3fed2ebcf
2 changed files with 21 additions and 1 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include "input-accessor.hh"
|
||||
#include "source-path.hh"
|
||||
#include "fetch-to-store.hh"
|
||||
#include "json-utils.hh"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
|
|
@ -412,3 +413,20 @@ std::string publicKeys_to_string(const std::vector<PublicKey>& publicKeys)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
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) };
|
||||
}
|
||||
|
||||
void adl_serializer<fetchers::PublicKey>::to_json(json & json, fetchers::PublicKey p) {
|
||||
json["type"] = p.type;
|
||||
json["key"] = p.key;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue