finish parse json

This commit is contained in:
John Bintz 2009-11-22 15:56:00 -05:00
parent 1aca4598a8
commit 5ebf8b450e
2 changed files with 4 additions and 2 deletions

View File

@ -4,7 +4,7 @@ class PostFixtures {
function parse_json($input) { function parse_json($input) {
if (($data = json_decode($input)) !== false) { if (($data = json_decode($input)) !== false) {
if (is_array($data) || is_object($data)) { if (is_array($data) || is_object($data)) {
return (array)$data; return array_values((array)$data);
} }
} }
return false; return false;

View File

@ -17,7 +17,9 @@ class PostFixturesTest extends PHPUnit_Framework_TestCase {
array('', false), array('', false),
array('{]', false), array('{]', false),
array('{}', array()), array('{}', array()),
array('[]', array()) array('[]', array()),
array('["test", "test2"]', array('test', 'test2')),
array('{"one": "test", "two": "test2"}', array('test', 'test2'))
); );
} }