diff --git a/lib/base/json.cpp b/lib/base/json.cpp index d9e1718c2e3..fbb59411c90 100644 --- a/lib/base/json.cpp +++ b/lib/base/json.cpp @@ -10,6 +10,7 @@ #include "base/utility.hpp" #include #include +#include #include #include #include @@ -365,7 +366,17 @@ inline void JsonEncoder::NumberFloat(double value) { BeforeItem(); - AppendJson(value); + + if (floor(value) == value) { + // Make sure 0.0 is serialized as 0, so Icinga DB can parse it as int. + if (value < 0) { + AppendJson((long long)value); + } else { + AppendJson((unsigned long long)value); + } + } else { + AppendJson(value); + } } template