BUGFIX Fixed Convert::json2array() from dying if Convert::json2obj() returns false

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@77428 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-05-20 22:52:33 +00:00
parent 2a66b5a8e1
commit 310a85cd9e

View File

@ -155,14 +155,21 @@ class Convert extends Object {
}
/**
* Convert a JSON string into an array.
*
* @uses json2obj
* @param string $val JSON string to convert
* @return array|boolean
*/
static function json2array($val) {
$json = self::json2obj($val);
if(!$json) return false;
$arr = array();
foreach($json as $k => $v) {
$arr[$k] = $v;
}
return $arr;
}