namespace Magento\Framework\Serialize\Serializer; use Magento\Framework\Serialize\SerializerInterface; /** * Serialize data to JSON, unserialize JSON encoded data * * @api * @since 101.0.0 */ class Json implements SerializerInterface { /** * @inheritDoc * @since 101.0.0 */ public function serialize($data) { $result = json_encode(utf8ize($data)); if (false === $result) { throw new \InvalidArgumentException("Unable to serialize value2. Error: " . json_last_error_msg() ); } return $result; } /** * @inheritDoc * @since 101.0.0 */ public function unserialize($string) { $result = json_decode($string, true); if (json_last_error() !== JSON_ERROR_NONE) { throw new \InvalidArgumentException("Unable to unserialize value. Error: " . json_last_error_msg()); } return $result; } } function utf8ize( $mixed ) { if (is_array($mixed)) { foreach ($mixed as $key => $value) { $mixed[$key] = utf8ize($value); } } elseif (is_string($mixed)) { return mb_convert_encoding($mixed, "UTF-8", "UTF-8"); } return $mixed; }
Fatal error: Uncaught Error: Class 'Magento\Framework\Serialize\Serializer\Json' not found in /home/nginx/www/vendor/magento/framework/ObjectManager/Factory/Compiled.php:60 Stack trace: #0 /home/nginx/www/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Framewo...') #1 /home/nginx/www/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\\Framewo...') #2 /home/nginx/www/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Framewo...') #3 /home/nginx/www/vendor/magento/framework/Interception/Config/Config.php(117): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...') #4 /home/nginx/www/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(116): Magento\Framework\Interception\Config\Config->__construct(Object(Magento\Framework\ObjectManager\Config\Reader\Dom\Pr in /home/nginx/www/vendor/magento/framework/ObjectManager/Factory/Compiled.php on line 60