mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Fixed regression of Convert::json2obj() not working when json_decode() is being used (from r100461)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@105571 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
d5e48d55dc
commit
dd7e7f813d
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user