mirror of
https://github.com/NixOS/nix.git
synced 2025-11-20 01:09:37 +01:00
Merge pull request #14504 from obsidiansystems/json-along-side-rpc-proto-test-data
JSON alongside binary proto serialization test data
This commit is contained in:
commit
091c0a97e1
60 changed files with 1097 additions and 42 deletions
|
|
@ -153,4 +153,20 @@ BuildResult adl_serializer<BuildResult>::from_json(const json & _json)
|
|||
return br;
|
||||
}
|
||||
|
||||
KeyedBuildResult adl_serializer<KeyedBuildResult>::from_json(const json & json0)
|
||||
{
|
||||
auto json = getObject(json0);
|
||||
|
||||
return KeyedBuildResult{
|
||||
adl_serializer<BuildResult>::from_json(json0),
|
||||
valueAt(json, "path"),
|
||||
};
|
||||
}
|
||||
|
||||
void adl_serializer<KeyedBuildResult>::to_json(json & json, const KeyedBuildResult & kbr)
|
||||
{
|
||||
adl_serializer<BuildResult>::to_json(json, kbr);
|
||||
json["path"] = kbr.path;
|
||||
}
|
||||
|
||||
} // namespace nlohmann
|
||||
|
|
|
|||
|
|
@ -178,3 +178,4 @@ struct KeyedBuildResult : BuildResult
|
|||
} // namespace nix
|
||||
|
||||
JSON_IMPL(nix::BuildResult)
|
||||
JSON_IMPL(nix::KeyedBuildResult)
|
||||
|
|
|
|||
|
|
@ -197,3 +197,4 @@ using ValidPathInfos = std::map<StorePath, ValidPathInfo>;
|
|||
} // namespace nix
|
||||
|
||||
JSON_IMPL(nix::UnkeyedValidPathInfo)
|
||||
JSON_IMPL(nix::ValidPathInfo)
|
||||
|
|
|
|||
|
|
@ -182,5 +182,6 @@ public:
|
|||
|
||||
} // namespace nix
|
||||
|
||||
JSON_IMPL(nix::DrvOutput)
|
||||
JSON_IMPL(nix::UnkeyedRealisation)
|
||||
JSON_IMPL(nix::Realisation)
|
||||
|
|
|
|||
|
|
@ -1004,4 +1004,10 @@ const ContentAddress * getDerivationCA(const BasicDerivation & drv);
|
|||
std::map<DrvOutput, StorePath>
|
||||
drvOutputReferences(Store & store, const Derivation & drv, const StorePath & outputPath, Store * evalStore = nullptr);
|
||||
|
||||
template<>
|
||||
struct json_avoids_null<TrustedFlag> : std::true_type
|
||||
{};
|
||||
|
||||
} // namespace nix
|
||||
|
||||
JSON_IMPL(nix::TrustedFlag)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "nix/util/closure.hh"
|
||||
#include "nix/store/filetransfer.hh"
|
||||
#include "nix/util/strings.hh"
|
||||
#include "nix/util/json-utils.hh"
|
||||
|
||||
#include <boost/unordered/unordered_flat_set.hpp>
|
||||
|
||||
|
|
@ -482,3 +483,19 @@ OutputPathMap resolveDerivedPath(Store & store, const DerivedPath::Built & bfd)
|
|||
}
|
||||
|
||||
} // namespace nix
|
||||
|
||||
namespace nlohmann {
|
||||
|
||||
using namespace nix;
|
||||
|
||||
TrustedFlag adl_serializer<TrustedFlag>::from_json(const json & json)
|
||||
{
|
||||
return getBoolean(json) ? TrustedFlag::Trusted : TrustedFlag::NotTrusted;
|
||||
}
|
||||
|
||||
void adl_serializer<TrustedFlag>::to_json(json & json, const TrustedFlag & trustedFlag)
|
||||
{
|
||||
json = static_cast<bool>(trustedFlag);
|
||||
}
|
||||
|
||||
} // namespace nlohmann
|
||||
|
|
|
|||
|
|
@ -251,4 +251,20 @@ void adl_serializer<UnkeyedValidPathInfo>::to_json(json & json, const UnkeyedVal
|
|||
json = c.toJSON(nullptr, true);
|
||||
}
|
||||
|
||||
ValidPathInfo adl_serializer<ValidPathInfo>::from_json(const json & json0)
|
||||
{
|
||||
auto json = getObject(json0);
|
||||
|
||||
return ValidPathInfo{
|
||||
valueAt(json, "path"),
|
||||
adl_serializer<UnkeyedValidPathInfo>::from_json(json0),
|
||||
};
|
||||
}
|
||||
|
||||
void adl_serializer<ValidPathInfo>::to_json(json & json, const ValidPathInfo & v)
|
||||
{
|
||||
adl_serializer<UnkeyedValidPathInfo>::to_json(json, v);
|
||||
json["path"] = v.path;
|
||||
}
|
||||
|
||||
} // namespace nlohmann
|
||||
|
|
|
|||
|
|
@ -144,6 +144,16 @@ namespace nlohmann {
|
|||
|
||||
using namespace nix;
|
||||
|
||||
DrvOutput adl_serializer<DrvOutput>::from_json(const json & json)
|
||||
{
|
||||
return DrvOutput::parse(getString(json));
|
||||
}
|
||||
|
||||
void adl_serializer<DrvOutput>::to_json(json & json, const DrvOutput & drvOutput)
|
||||
{
|
||||
json = drvOutput.to_string();
|
||||
}
|
||||
|
||||
UnkeyedRealisation adl_serializer<UnkeyedRealisation>::from_json(const json & json0)
|
||||
{
|
||||
auto json = getObject(json0);
|
||||
|
|
@ -182,14 +192,14 @@ Realisation adl_serializer<Realisation>::from_json(const json & json0)
|
|||
|
||||
return Realisation{
|
||||
static_cast<UnkeyedRealisation>(json0),
|
||||
DrvOutput::parse(valueAt(json, "id")),
|
||||
valueAt(json, "id"),
|
||||
};
|
||||
}
|
||||
|
||||
void adl_serializer<Realisation>::to_json(json & json, const Realisation & r)
|
||||
{
|
||||
json = static_cast<const UnkeyedRealisation &>(r);
|
||||
json["id"] = r.id.to_string();
|
||||
json["id"] = r.id;
|
||||
}
|
||||
|
||||
} // namespace nlohmann
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue