renderArray() public method

public renderArray ( $array )
コード例 #1
0
ファイル: Json2.php プロジェクト: FluentDevelopment/piwik
 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;
 }
コード例 #2
0
ファイル: JsonRendererTest.php プロジェクト: a4tunado/piwik
 /**
  * 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);
 }