dionajie
dionajie

Reputation: 404

json_encode return some weird characters

I'm trying to grab data from twitter. I'm success to return data to array. BUt, when i change it to json using json_encode, some data have weird characters.

{
   "name": "\u24d7\u24d8\u24db",
   "url": "http:\/\/t.co\/m3rqX58egq",
}

what's wrong? is it related to utf8 encode and JSON_UNESCAPED_SLASHES?

Upvotes: 1

Views: 523

Answers (2)

Roshan Shelar
Roshan Shelar

Reputation: 248

Yes it is related to JSON_UNESCAPED_SLASHES and it is available since PHP 5.4.0.

return json_encode($array,JSON_UNESCAPED_SLASHES);

Upvotes: 4

JordyBobs
JordyBobs

Reputation: 137

This is likely due to the Special characters coming back in the JSON, Have a look at htmlSpecialChars() Or see this answer

Upvotes: 0

Related Questions