diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-05-04 11:58:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-04 11:58:20 +0200 |
commit | 470e27ce8008ba952225b9f9f7f61a9627376f33 (patch) | |
tree | 26f93c989175825996538b6e8aae4af5ed28bfa0 /src/libutil/json-utils.hh | |
parent | 1385b2007804c8a0370f2a6555045a00e34b07c7 (diff) | |
parent | 107613ad2b2b61ef92edf9ee53ec71ad664be71b (diff) |
Merge pull request #6482 from edolstra/json-utils
Move json stuff out of util.cc
Diffstat (limited to 'src/libutil/json-utils.hh')
-rw-r--r-- | src/libutil/json-utils.hh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libutil/json-utils.hh b/src/libutil/json-utils.hh new file mode 100644 index 000000000..b8a031227 --- /dev/null +++ b/src/libutil/json-utils.hh @@ -0,0 +1,21 @@ +#pragma once + +#include <nlohmann/json.hpp> + +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; +} + +} |