json_encode would make special character fields null / UTF8 Encoding

I was trying to deal with a large data set and converting it to JSON. Realized that some json fields were null if they contained special characters. Therefore, I had to convert the data to utf-8 charset before creating a json.

$encoded-data = utf8_encode($data_with_spl_char);
Advertisements
Posted in PHP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s