aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/json-impls.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/json-impls.hh')
-rw-r--r--src/libutil/json-impls.hh14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libutil/json-impls.hh b/src/libutil/json-impls.hh
new file mode 100644
index 000000000..bd75748ad
--- /dev/null
+++ b/src/libutil/json-impls.hh
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "nlohmann/json_fwd.hpp"
+
+// Following https://github.com/nlohmann/json#how-can-i-use-get-for-non-default-constructiblenon-copyable-types
+#define JSON_IMPL(TYPE) \
+ namespace nlohmann { \
+ using namespace nix; \
+ template <> \
+ struct adl_serializer<TYPE> { \
+ static TYPE from_json(const json & json); \
+ static void to_json(json & json, TYPE t); \
+ }; \
+ }