mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
2a66b5a8e1
commit
310a85cd9e
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user