cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded

Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded

Hello guys.

 

I just installed Magento 2.3.2 on my local MAMP server, with composer.

Installation is completely clean. I do nothing yet.

The problem is - when I trying to configure Extension Manager after put my keys and pressing submit button I have this error message -  Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded.

 

Please help me with this problem

2 REPLIES 2

Re: Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded

Having same issue here too any clue Smiley Happy

Re: Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded

Correct your file:


@tattoowizards wrote:

Hello guys.

 

I just installed Magento 2.3.2 on my local MAMP server, with composer.

Installation is completely clean. I do nothing yet.

The problem is - when I trying to configure Extension Manager after put my keys and pressing submit button I have this error message -  Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded.

 

Please help me with this problem


Correct your file
..vendor/magento/framework/Serialize/Serializer/Json.php

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;
}