From baa158bb331e6bf54edf86204c70289b3c9a55c2 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Thu, 17 Jun 2021 21:30:06 +0200 Subject: [PATCH] Add helper fromatJsonString() obs_data_get_json() will now dump the json data in JSON_COMPACT format which makes it rather difficult to read. --- src/headers/utility.hpp | 2 ++ src/utility.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/headers/utility.hpp b/src/headers/utility.hpp index f8da16c7..440e6c8c 100644 --- a/src/headers/utility.hpp +++ b/src/headers/utility.hpp @@ -28,6 +28,8 @@ bool compareSourceSettings(const OBSWeakSource &source, std::vector getSceneItemsWithName(OBSScene scene, std::string &name); std::string getDataFilePath(const std::string &file); +QString fromatJsonString(std::string); +QString fromatJsonString(const char *); /** * Populate layout with labels and widgets based on provided text diff --git a/src/utility.cpp b/src/utility.cpp index 7f655eea..9aaccdcd 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -291,6 +292,17 @@ std::string getDataFilePath(const std::string &file) return ""; } +QString fromatJsonString(std::string s) +{ + return fromatJsonString(s.c_str()); +} + +QString fromatJsonString(const char *json) +{ + QJsonDocument doc = QJsonDocument::fromJson(json); + return doc.toJson(QJsonDocument::Indented); +} + bool DisplayMessage(const QString &msg, bool question) { if (question) {