Skip to content

Commit 2c9037a

Browse files
fixing problem with string values returning as numeric data. and the
beginnings of my work on getting complex CSV data to work.
1 parent e75883e commit 2c9037a

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

src/SoapBox/Formatter/Formatter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public function to_csv($data = null, $attributes = null) {
164164
} else {
165165
$headings = array_shift($data);
166166
}
167+
167168
}
168169
// Single array
169170
else {
@@ -210,7 +211,7 @@ public function to_json($data = null, $pretty = false) {
210211
// To allow exporting ArrayAccess objects like Orm\Model instances they need to be
211212
// converted to an array first
212213
$data = (is_array($data) or is_object($data)) ? $this->to_array($data) : $data;
213-
return $pretty ? static::pretty_json($data) : json_encode($data, JSON_NUMERIC_CHECK);
214+
return $pretty ? static::pretty_json($data) : json_encode($data);
214215
}
215216

216217
/**

tests/FormatterTest.php

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,46 @@ public function testCSVToArray() {
6060
$this->assertEquals($expected, $result);
6161
}
6262

63-
}
63+
/**
64+
* A complex multi-dimentional test for CSV data to array
65+
*
66+
* @return void
67+
*/
68+
public function testComplexCSVToArray() {
69+
/*
70+
$data = '
71+
{
72+
"simple":"118",
73+
"date":"2014-05-20 21:03:59.333",
74+
"time":"4067",
75+
"duration_onset":null,
76+
"devicename":"My Device",
77+
"calc_data":[
78+
[
79+
1400609039,
80+
0,
81+
37,
82+
0,
83+
0,
84+
1
85+
],
86+
[
87+
1400609039,
88+
0,
89+
37,
90+
0,
91+
0,
92+
1
93+
]
94+
]
95+
}
96+
';
97+
98+
$result = Formatter::make($data, 'json')->to_csv();
99+
100+
dd($result);
101+
*/
102+
$this->assertEquals(true,true);
103+
}
104+
105+
}

0 commit comments

Comments
 (0)