diff --git a/src/Control/PjaxResponseNegotiator.php b/src/Control/PjaxResponseNegotiator.php index 53557a7ea..e87d104e2 100644 --- a/src/Control/PjaxResponseNegotiator.php +++ b/src/Control/PjaxResponseNegotiator.php @@ -102,7 +102,7 @@ class PjaxResponseNegotiator throw new HTTPResponse_Exception("X-Pjax = '$fragment' not supported for this URL.", 400); } } - $response->setBody(Convert::raw2json($responseParts)); + $response->setBody(json_encode($responseParts)); $response->addHeader('Content-Type', 'application/json'); return $response; diff --git a/src/Core/Manifest/VersionProvider.php b/src/Core/Manifest/VersionProvider.php index c2f307931..fee190057 100644 --- a/src/Core/Manifest/VersionProvider.php +++ b/src/Core/Manifest/VersionProvider.php @@ -95,12 +95,12 @@ class VersionProvider $cache = Injector::inst()->get(CacheInterface::class . '.VersionProvider_composerlock'); $cacheKey = md5($jsonData); if ($versions = $cache->get($cacheKey)) { - $lockData = Convert::json2array($versions); + $lockData = json_decode($versions, true); } } if (empty($lockData) && $jsonData) { - $lockData = Convert::json2array($jsonData); + $lockData = json_decode($jsonData, true); if ($cache) { $cache->set($cacheKey, $jsonData); diff --git a/src/Forms/FormRequestHandler.php b/src/Forms/FormRequestHandler.php index 4392ab3bc..835b0762c 100644 --- a/src/Forms/FormRequestHandler.php +++ b/src/Forms/FormRequestHandler.php @@ -376,7 +376,7 @@ class FormRequestHandler extends RequestHandler $acceptType = $this->getRequest()->getHeader('Accept'); if (strpos($acceptType, 'application/json') !== false) { // Send validation errors back as JSON with a flag at the start - $response = new HTTPResponse(Convert::array2json($result->getMessages())); + $response = new HTTPResponse(json_encode($result->getMessages())); $response->addHeader('Content-Type', 'application/json'); return $response; } diff --git a/src/Forms/GridField/GridFieldAddExistingAutocompleter.php b/src/Forms/GridField/GridFieldAddExistingAutocompleter.php index 48a45a945..290cdb749 100644 --- a/src/Forms/GridField/GridFieldAddExistingAutocompleter.php +++ b/src/Forms/GridField/GridFieldAddExistingAutocompleter.php @@ -262,7 +262,7 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF ); } Config::unnest(); - $response = new HTTPResponse(Convert::array2json($json)); + $response = new HTTPResponse(json_encode($json)); $response->addHeader('Content-Type', 'application/json'); return $response; } diff --git a/src/Forms/GridField/GridFieldFilterHeader.php b/src/Forms/GridField/GridFieldFilterHeader.php index fd3dd8ea9..802340d78 100755 --- a/src/Forms/GridField/GridFieldFilterHeader.php +++ b/src/Forms/GridField/GridFieldFilterHeader.php @@ -291,7 +291,7 @@ class GridFieldFilterHeader implements GridField_URLHandler, GridField_HTMLProvi 'clearAction' => GridField_FormAction::create($gridField, 'reset', false, 'reset', null)->getAttribute('name') ]; - return Convert::raw2json($schema); + return json_encode($schema); } /** @@ -377,7 +377,7 @@ class GridFieldFilterHeader implements GridField_URLHandler, GridField_HTMLProvi $data = FormSchema::singleton() ->getMultipartSchema($parts, $schemaID, $form); - $response = new HTTPResponse(Convert::raw2json($data)); + $response = new HTTPResponse(json_encode($data)); $response->addHeader('Content-Type', 'application/json'); return $response; } diff --git a/src/Forms/GridField/GridField_ActionMenu.php b/src/Forms/GridField/GridField_ActionMenu.php index 1dfff1a6d..351f38a3d 100644 --- a/src/Forms/GridField/GridField_ActionMenu.php +++ b/src/Forms/GridField/GridField_ActionMenu.php @@ -48,7 +48,7 @@ class GridField_ActionMenu implements GridField_ColumnProvider, GridField_Action } $templateData = ArrayData::create([ - 'Schema' => Convert::raw2json($schema), + 'Schema' => json_encode($schema), ]); $template = SSViewer::get_templates_by_class($this, '', static::class); diff --git a/src/Forms/HTMLEditor/TinyMCEConfig.php b/src/Forms/HTMLEditor/TinyMCEConfig.php index 9dbeb3ceb..06314e750 100644 --- a/src/Forms/HTMLEditor/TinyMCEConfig.php +++ b/src/Forms/HTMLEditor/TinyMCEConfig.php @@ -371,7 +371,7 @@ class TinyMCEConfig extends HTMLEditorConfig { return [ 'data-editor' => 'tinyMCE', // Register ss.editorWrappers.tinyMCE - 'data-config' => Convert::array2json($this->getConfig()), + 'data-config' => json_encode($this->getConfig()), ]; } diff --git a/src/ORM/FieldType/DBField.php b/src/ORM/FieldType/DBField.php index 70aa13cb4..20be1e08d 100644 --- a/src/ORM/FieldType/DBField.php +++ b/src/ORM/FieldType/DBField.php @@ -487,7 +487,7 @@ abstract class DBField extends ViewableData implements DBIndexable */ public function JSON() { - return Convert::raw2json($this->RAW()); + return json_encode($this->RAW()); } /** diff --git a/tests/php/Forms/GridField/GridFieldAddExistingAutocompleterTest.php b/tests/php/Forms/GridField/GridFieldAddExistingAutocompleterTest.php index b5a017845..2a427700a 100644 --- a/tests/php/Forms/GridField/GridFieldAddExistingAutocompleterTest.php +++ b/tests/php/Forms/GridField/GridFieldAddExistingAutocompleterTest.php @@ -64,7 +64,7 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest array((string)$btns[0]['name'] => 1) ); $this->assertFalse($response->isError()); - $result = Convert::json2array($response->getBody()); + $result = json_decode($response->getBody(), true); $this->assertEquals(1, count($result)); $this->assertEquals( array(array( @@ -81,7 +81,7 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest array((string)$btns[0]['name'] => 1) ); $this->assertFalse($response->isError()); - $result = Convert::json2array($response->getBody()); + $result = json_decode($response->getBody(), true); $this->assertEquals(1, count($result), "The relational filter did not work"); $response = $this->post( @@ -90,7 +90,7 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest array((string)$btns[0]['name'] => 1) ); $this->assertFalse($response->isError()); - $result = Convert::json2array($response->getBody()); + $result = json_decode($response->getBody(), true); $this->assertEmpty($result, 'The output is either an empty array or boolean FALSE'); } diff --git a/tests/php/Forms/HTMLEditor/HTMLEditorConfigTest.php b/tests/php/Forms/HTMLEditor/HTMLEditorConfigTest.php index da665a96f..8b1fa62f5 100644 --- a/tests/php/Forms/HTMLEditor/HTMLEditorConfigTest.php +++ b/tests/php/Forms/HTMLEditor/HTMLEditorConfigTest.php @@ -69,7 +69,7 @@ class HTMLEditorConfigTest extends SapphireTest ) ); $attributes = $c->getAttributes(); - $config = Convert::json2array($attributes['data-config']); + $config = json_decode($attributes['data-config'], true); $plugins = $config['external_plugins']; $this->assertNotEmpty($plugins);