mirror of
https://github.com/NixOS/nix
synced 2025-06-27 12:41:15 +02:00
Create nlohmann serializers for std::optional
and use
This is somewhat tricky.
This commit is contained in:
parent
3b0d8fd796
commit
c8825e9d8c
4 changed files with 97 additions and 25 deletions
19
src/libutil/json-utils.cc
Normal file
19
src/libutil/json-utils.cc
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include "json-utils.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
const nlohmann::json * get(const nlohmann::json & map, const std::string & key)
|
||||
{
|
||||
auto i = map.find(key);
|
||||
if (i == map.end()) return nullptr;
|
||||
return &*i;
|
||||
}
|
||||
|
||||
nlohmann::json * get(nlohmann::json & map, const std::string & key)
|
||||
{
|
||||
auto i = map.find(key);
|
||||
if (i == map.end()) return nullptr;
|
||||
return &*i;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue