Deprecation:
Inheritance: extends Piwik\API\ApiRenderer
Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 /**
  * backwards compatibility test
  */
 public function test_oldJson_renderArray_ShouldConvertSingleDimensionalAssociativeArray()
 {
     $input = array("firstElement" => "isFirst", "secondElement" => "isSecond");
     $expected = '[{"firstElement":"isFirst","secondElement":"isSecond"}]';
     $oldJsonBuilder = new Json($input);
     $actual = $oldJsonBuilder->renderArray($input);
     $this->assertEquals($expected, $actual);
     $this->assertNoJsonError($actual);
 }