Skip to content

Commit

Permalink
fixing problem with string values returning as numeric data. and the
Browse files Browse the repository at this point in the history
beginnings of my work on  getting complex CSV data to work.
  • Loading branch information
grahammccarthy committed Aug 19, 2014
1 parent e75883e commit 2c9037a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/SoapBox/Formatter/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public function to_csv($data = null, $attributes = null) {
} else {
$headings = array_shift($data);
}

}
// Single array
else {
Expand Down Expand Up @@ -210,7 +211,7 @@ public function to_json($data = null, $pretty = false) {
// To allow exporting ArrayAccess objects like Orm\Model instances they need to be
// converted to an array first
$data = (is_array($data) or is_object($data)) ? $this->to_array($data) : $data;
return $pretty ? static::pretty_json($data) : json_encode($data, JSON_NUMERIC_CHECK);
return $pretty ? static::pretty_json($data) : json_encode($data);
}

/**
Expand Down
44 changes: 43 additions & 1 deletion tests/FormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,46 @@ public function testCSVToArray() {
$this->assertEquals($expected, $result);
}

}
/**
* A complex multi-dimentional test for CSV data to array
*
* @return void
*/
public function testComplexCSVToArray() {
/*
$data = '
{
"simple":"118",
"date":"2014-05-20 21:03:59.333",
"time":"4067",
"duration_onset":null,
"devicename":"My Device",
"calc_data":[
[
1400609039,
0,
37,
0,
0,
1
],
[
1400609039,
0,
37,
0,
0,
1
]
]
}
';
$result = Formatter::make($data, 'json')->to_csv();
dd($result);
*/
$this->assertEquals(true,true);
}

}

0 comments on commit 2c9037a

Please sign in to comment.