Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

JSONRPC: added advancedsettings option to disable/enable compact json…

… output

The default output format for json (responses and announcements) has been changed to a compact print.
This can be disabled (pretty print) by setting <jsonrpc><compactjson>false</compactjson></jsonrpc> in advancedsettings.xml.
  • Loading branch information...
commit 20e18ee556b324da8f836ec9eb6678840297d7d7 1 parent a1446a3
@Montellese Montellese authored
View
13 xbmc/interfaces/json-rpc/JSONRPC.cpp
@@ -30,6 +30,7 @@
#include "VideoLibrary.h"
#include "SystemOperations.h"
#include "XBMCOperations.h"
+#include "settings/AdvancedSettings.h"
#include "interfaces/AnnouncementManager.h"
#include "utils/log.h"
#include "utils/Variant.h"
@@ -355,10 +356,18 @@ CStdString CJSONRPC::MethodCall(const CStdString &inputString, ITransportLayer *
hasResponse = true;
}
- StyledWriter writer;
CStdString str;
if (hasResponse)
- str = writer.write(outputroot);
+ {
+ Writer *writer;
+ if (g_advancedSettings.m_jsonOutputCompact)
+ writer = new FastWriter();
+ else
+ writer = new StyledWriter();
+
+ str = writer->write(outputroot);
+ delete writer;
+ }
return str;
}
View
11 xbmc/network/TCPServer.cpp
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
+#include "settings/AdvancedSettings.h"
#include "interfaces/json-rpc/JSONRPC.h"
#include "jsoncpp/include/json/json.h"
#include "interfaces/AnnouncementManager.h"
@@ -149,8 +150,14 @@ void CTCPServer::Announce(EAnnouncementFlag flag, const char *sender, const char
if (!data.isNull())
data.toJsonValue(root["params"]["data"]);
- StyledWriter writer;
- std::string str = writer.write(root);
+ Writer *writer;
+ if (g_advancedSettings.m_jsonOutputCompact)
+ writer = new FastWriter();
+ else
+ writer = new StyledWriter();
+
+ std::string str = writer->write(root);
+ delete writer;
for (unsigned int i = 0; i < m_connections.size(); i++)
{
View
8 xbmc/settings/AdvancedSettings.cpp
@@ -272,6 +272,8 @@ void CAdvancedSettings::Initialize()
m_measureRefreshrate = false;
m_cacheMemBufferSize = (1048576 * 5);
+
+ m_jsonOutputCompact = true;
}
bool CAdvancedSettings::Load()
@@ -582,6 +584,12 @@ bool CAdvancedSettings::Load()
XMLUtils::GetUInt(pElement, "cachemembuffersize", m_cacheMemBufferSize);
}
+ pElement = pRootElement->FirstChildElement("jsonrpc");
+ if (pElement)
+ {
+ XMLUtils::GetBoolean(pElement, "compactoutput", m_jsonOutputCompact);
+ }
+
pElement = pRootElement->FirstChildElement("samba");
if (pElement)
{
View
2  xbmc/settings/AdvancedSettings.h
@@ -283,6 +283,8 @@ class CAdvancedSettings
DatabaseSettings m_databaseVideo; // advanced video database setup
unsigned int m_cacheMemBufferSize;
+
+ bool m_jsonOutputCompact;
};
extern CAdvancedSettings g_advancedSettings;
Please sign in to comment.
Something went wrong with that request. Please try again.