aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/json-utils.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/json-utils.cc')
-rw-r--r--src/libutil/json-utils.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libutil/json-utils.cc b/src/libutil/json-utils.cc
new file mode 100644
index 000000000..d7220e71d
--- /dev/null
+++ b/src/libutil/json-utils.cc
@@ -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;
+}
+
+}