diff --git a/src/json_utils.h b/src/json_utils.h
new file mode 100644
index 000000000..c70fad5ce
--- /dev/null
+++ b/src/json_utils.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2004-2024 Savoir-faire Linux Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#pragma once
+
+#include
+#include
+#include
+
+namespace jami {
+
+extern const Json::CharReaderBuilder rbuilder;
+
+inline bool parseJson(std::string_view jsonStr, Json::Value& json) {
+ std::string err;
+ auto reader = std::unique_ptr(rbuilder.newCharReader());
+ if (!reader->parse(jsonStr.data(),
+ jsonStr.data() + jsonStr.size(),
+ &json,
+ &err)) {
+ JAMI_WARNING("Can't parse JSON: {}\n{}", err, jsonStr);
+ return false;
+ }
+ return true;
+}
+
+}
diff --git a/src/string_utils.cpp b/src/string_utils.cpp
index fb11b0f44..e1830e263 100644
--- a/src/string_utils.cpp
+++ b/src/string_utils.cpp
@@ -39,8 +39,19 @@
#include // fix windows compiler bug
+#include "json_utils.h"
+
namespace jami {
+Json::CharReaderBuilder getJsonReaderBuilder()
+{
+ Json::CharReaderBuilder builder;
+ builder["collectComments"] = false;
+ return builder;
+}
+
+const Json::CharReaderBuilder rbuilder = getJsonReaderBuilder();
+
std::string_view
userAgent()
{