writeLockFile(): Emit empty objects rather than null

This commit is contained in:
Eelco Dolstra 2019-04-16 14:23:10 +02:00
parent ed9d725392
commit e1d73edb10

View file

@ -114,9 +114,10 @@ void writeLockFile(LockFile lockFile, Path path)
{
nlohmann::json json;
json["version"] = 1;
json["nonFlakeRequires"];
json["nonFlakeRequires"] = nlohmann::json::object();
for (auto & x : lockFile.nonFlakeEntries)
json["nonFlakeRequires"][x.first]["uri"] = x.second.to_string();
json["requires"] = nlohmann::json::object();
for (auto & x : lockFile.flakeEntries)
json["requires"][x.first] = flakeEntryToJson(x.second);
createDirs(dirOf(path));