Ionut Flavius Pogacian
Ionut Flavius Pogacian

Reputation: 4801

Yii2 json_encode Invalid UTF-8 sequence in argument

I am trying to signup, after i made a composer update for Yii2 and I get the following error:

PHP Warning – yii\base\ErrorException

json_encode(): Invalid UTF-8 sequence in argument

The error is where the model attributes array is encoded as a json:

Json::encode($this->owner->attributes)

Upvotes: 2

Views: 2797

Answers (1)

Mihai P.
Mihai P.

Reputation: 9357

http://php.net/manual/en/function.json-encode.php
All string data must be UTF-8 encoded.

Do you by any chance have diacritics in the attributes of the model? You might need to transform them to UTF-8 before you encode them.

Upvotes: 1

Related Questions