Fix the top level JSON category.

This commit is contained in:
Jonathan Naylor
2023-01-01 18:54:21 +00:00
parent 38a6dbbdeb
commit 2090432a6a
4 changed files with 53 additions and 43 deletions

11
Log.cpp
View File

@@ -200,9 +200,14 @@ void Log(unsigned int level, const char* fmt, ...)
}
}
void WriteJSON(const std::string& json)
void WriteJSON(const std::string& topLevel, nlohmann::json& json)
{
if (m_mqtt != NULL)
m_mqtt->publish("json", json.c_str());
if (m_mqtt != NULL) {
nlohmann::json top;
top[topLevel] = json;
m_mqtt->publish("json", top.dump().c_str());
}
}