MINOR Fixed regression of Convert::json2obj() not working when json_decode() is being used

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@100461 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2010-03-04 02:05:09 +00:00 committed by Sam Minnee
parent 20cbc51554
commit 4eb50972c3

View File

@ -140,8 +140,7 @@ class Convert extends Object {
}
/**
* Uses the PHP 5.2 native json_encode function if available,
* otherwise falls back to the Services_JSON class.
* Convert an array into a JSON encoded string.
*
* @see http://pear.php.net/pepr/pepr-proposal-show.php?id=198
* @uses Director::baseFolder()
@ -161,8 +160,7 @@ class Convert extends Object {
}
/**
* Uses the PHP 5.2 native json_decode function if available,
* otherwise falls back to the Services_JSON class.
* Convert a JSON encoded string into an object.
*
* @see http://pear.php.net/pepr/pepr-proposal-show.php?id=198
* @uses Director::baseFolder()
@ -172,13 +170,9 @@ class Convert extends Object {
* @return mixed JSON safe string
*/
static function json2obj($val) {
if(function_exists('json_decode')) {
return json_decode($val);
} else {
require_once(Director::baseFolder() . '/sapphire/thirdparty/json/JSON.php');
$json = new Services_JSON();
return $json->decode($val);
}
require_once(Director::baseFolder() . '/sapphire/thirdparty/json/JSON.php');
$json = new Services_JSON();
return $json->decode($val);
}
/**