Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Aubry <mattab@users.noreply.github.com>2016-12-05 15:06:51 +0300
committerGitHub <noreply@github.com>2016-12-05 15:06:51 +0300
commit46eafa8ab66d9d7bc785dc6697b8c3168c9d4145 (patch)
treee8f660cf251252160b60c3d39968ca5c623c6b0e /plugins/API/Renderer/Json2.php
parent95dff7b6812f54c1afc67d6781a5d01d47c3ca60 (diff)
parent1d0dcc553611b551bd8a621a0790f91b897968dd (diff)
Merge pull request #10965 from piwik/3.x-dev3.0.0-b5
Release Piwik 3.0.0-beta5
Diffstat (limited to 'plugins/API/Renderer/Json2.php')
-rw-r--r--plugins/API/Renderer/Json2.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/plugins/API/Renderer/Json2.php b/plugins/API/Renderer/Json2.php
index bd27810fb8..23f6effe0b 100644
--- a/plugins/API/Renderer/Json2.php
+++ b/plugins/API/Renderer/Json2.php
@@ -11,8 +11,24 @@ namespace Piwik\Plugins\API\Renderer;
use Piwik\Piwik;
/**
- * Left here for Backward compatibility in Piwik 3.X+ for all users who correctly used format=json2 during Piwik 2.X
+ * Correct API output renderer for JSON. Includes bug fixes for bugs in the old JSON API
+ * format.
*/
class Json2 extends Json
{
-} \ No newline at end of file
+ public function renderArray($array)
+ {
+ $result = parent::renderArray($array);
+
+ // if $array is a simple associative array, remove the JSON root array that is added by renderDataTable
+ if (!empty($array)
+ && Piwik::isAssociativeArray($array)
+ && !Piwik::isMultiDimensionalArray($array)
+ ) {
+ $result = substr($result, 1, strlen($result) - 2);
+ }
+
+ return $result;
+ }
+}
+