diff --git a/doc/9-appendix.md b/doc/9-appendix.md
index d00ece34a..30765d928 100644
--- a/doc/9-appendix.md
+++ b/doc/9-appendix.md
@@ -147,6 +147,8 @@ Icinga 2 specific extensions:
* host and service objects support 'check_source' (added in Classic UI 1.10.0)
* command objects support custom variables (added in Classic UI 1.11.2)
* host and service objects support 'is_reachable' (added in Classic UI 1.11.3)
+* 2.2 adds custom attributes with arrays and dictionaries. They are dumped as JSON encoded string and `_is_json`
+is set as additional custom variable in `objects.cache`.
### DB IDO Schema
diff --git a/lib/compat/statusdatawriter.cpp b/lib/compat/statusdatawriter.cpp
index 73f5e48be..df57ce355 100644
--- a/lib/compat/statusdatawriter.cpp
+++ b/lib/compat/statusdatawriter.cpp
@@ -30,6 +30,7 @@
#include "icinga/dependency.hpp"
#include "base/dynamictype.hpp"
#include "base/objectlock.hpp"
+#include "base/json.hpp"
#include "base/convert.hpp"
#include "base/logger.hpp"
#include "base/exception.hpp"
@@ -514,6 +515,8 @@ void StatusDataWriter::DumpCustomAttributes(std::ostream& fp, const CustomVarObj
if (!vars)
return;
+ bool is_json = false;
+
ObjectLock olock(vars);
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
if (kv.first.IsEmpty())
@@ -521,9 +524,10 @@ void StatusDataWriter::DumpCustomAttributes(std::ostream& fp, const CustomVarObj
String value;
- if (kv.second.IsObjectType())
- value = Utility::Join(kv.second, ';');
- else
+ if (kv.second.IsObjectType() || kv.second.IsObjectType()) {
+ value = JsonEncode(kv.second);
+ is_json = true;
+ } else
value = kv.second;
fp << "\t";
@@ -533,6 +537,9 @@ void StatusDataWriter::DumpCustomAttributes(std::ostream& fp, const CustomVarObj
fp << kv.first << "\t" << value << "\n";
}
+
+ if (is_json)
+ fp << "\t" "_is_json" "\t" "1" "\n";
}
void StatusDataWriter::UpdateObjectsCache(void)