1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-08 06:53:54 +02:00

Merge pull request #10602 from haenoe/json-infra-tests-misc

Json infra tests misc
This commit is contained in:
John Ericson 2024-04-25 16:53:51 -04:00 committed by GitHub
commit 4722b0c9e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 64 additions and 13 deletions

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) {