From: Oliver Hader Date: Mon, 3 Nov 2008 16:57:00 +0000 (+0000) Subject: Fixed bug #9286: Use native JSON-methods instead of 3rd party JSON script X-Git-Tag: TYPO3_4-3-0alpha1~39 X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/commitdiff_plain/e232821dfb5f5be936a39afc93e91bf5dc48ff49 Fixed bug #9286: Use native JSON-methods instead of 3rd party JSON script git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@4413 709f56b5-9817-0410-a4d7-c38de5d9e867 --- diff --git a/ChangeLog b/ChangeLog index 2c95b82bd979..d263d6fcba53 100755 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * Added feature #9654: Enable includeLibs also for USER and COA objects * Fixed bug #9724: Editing shortcuts does not work anymore + * Fixed bug #9286: Use native JSON-methods instead of 3rd party JSON script (thanks to Steffen Kamper) 2008-11-01 Martin Kutschker diff --git a/t3lib/class.t3lib_div.php b/t3lib/class.t3lib_div.php index a6aa3033aadf..ebcf2859bd5d 100755 --- a/t3lib/class.t3lib_div.php +++ b/t3lib/class.t3lib_div.php @@ -1863,19 +1863,16 @@ final class t3lib_div { return $str; } - /** - * Creates recursively a JSON literal from a mulidimensional associative array. - * Uses Services_JSON (http://mike.teczno.com/JSON/doc/) + /** + * Creates recursively a JSON literal from a multidimensional associative array. + * Uses native function of PHP >= 5.2.0 * * @param array $jsonArray: The array to be transformed to JSON * @return string JSON string + * @deprecated since TYPO3 4.3, use PHP native function json_encode() instead, will be removed in TYPO3 4.5 */ public static function array2json(array $jsonArray) { - if (!$GLOBALS['JSON']) { - require_once(PATH_typo3.'contrib/json/json.php'); - $GLOBALS['JSON'] = t3lib_div::makeInstance('Services_JSON'); - } - return $GLOBALS['JSON']->encode($jsonArray); + return json_encode($jsonArray); } /** diff --git a/t3lib/class.t3lib_tceforms.php b/t3lib/class.t3lib_tceforms.php index 533ac0446cdd..69f9b50ed531 100755 --- a/t3lib/class.t3lib_tceforms.php +++ b/t3lib/class.t3lib_tceforms.php @@ -5189,19 +5189,19 @@ class t3lib_TCEforms { // add JS required for inline fields if (count($this->inline->inlineData)) { $out .= ' - inline.addToDataArray('.t3lib_div::array2json($this->inline->inlineData).'); + inline.addToDataArray(' . json_encode($this->inline->inlineData) . '); '; } // Registered nested elements for tabs or inline levels: if (count($this->requiredNested)) { $out .= ' - TBE_EDITOR.addNested('.t3lib_div::array2json($this->requiredNested).'); + TBE_EDITOR.addNested(' . json_encode($this->requiredNested) . '); '; } // elements which are required or have a range definition: if (count($elements)) { $out .= ' - TBE_EDITOR.addElements('.t3lib_div::array2json($elements).'); + TBE_EDITOR.addElements(' . json_encode($elements) . '); TBE_EDITOR.initRequired(); '; } @@ -5973,7 +5973,7 @@ class t3lib_TCEforms { if ($skipFirst) { array_shift($result); } - return ($json ? t3lib_div::array2json($result) : $result); + return ($json ? json_encode($result) : $result); } /** diff --git a/t3lib/class.t3lib_tceforms_inline.php b/t3lib/class.t3lib_tceforms_inline.php index 3c373f413aa6..2ac751e8811f 100755 --- a/t3lib/class.t3lib_tceforms_inline.php +++ b/t3lib/class.t3lib_tceforms_inline.php @@ -2245,10 +2245,10 @@ class t3lib_TCEforms_inline { * * @param array $jsonArray: The array (or part of) to be transformed to JSON * @return string If $level>0: part of JSON literal; if $level==0: whole JSON literal wrapped with