diff options
Diffstat (limited to 'plugins/API/Renderer/Json.php')
-rw-r--r-- | plugins/API/Renderer/Json.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/plugins/API/Renderer/Json.php b/plugins/API/Renderer/Json.php index 8adfdaebe1..1f7591370b 100644 --- a/plugins/API/Renderer/Json.php +++ b/plugins/API/Renderer/Json.php @@ -17,9 +17,6 @@ use Piwik\ProxyHttp; /** * API output renderer for JSON. * - * **NOTE: This is the old JSON format. It includes bugs that are fixed in the JSON2 API output - * format. Please use that format instead of this.** - * * @deprecated */ class Json extends ApiRenderer @@ -61,7 +58,17 @@ class Json extends ApiRenderer return $this->applyJsonpIfNeeded($result); } - return $this->renderDataTable($array); + $result = $this->renderDataTable($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; } public function sendHeader() |