PHP json_decode()

January 6th, 2008

So, I had my first run in with using PHP and JSON together. In PHP 5.2 and greater, there is native JSON support, so I started there first. It seemed to work just fine when the JSON objects were simple, but when they got complex and very nested, it failed every time.

After much hair pulling, a friend helped me out. The JSON I was getting back from the web service I was querying (Brightcove in this case) was not utf-8 encoded. Once I manually encoded it to utf-8, it worked.

But, it wasn’t over yet. I then ran into the issue that I couldn’t get any information out of the damn decoded response. However, once I passed a second optional argument to json_decode() (I passed in true), I was able to get my response as an associative array, and all was right with the world.

Since JSON itself is a relatively hot topic in web technologies, I wanted to throw this post out there to help people in case they run into the same issue I had.

One Response to “PHP json_decode()”

  1. ALLEN Says:


    MedicamentSpot.com. Canadian Health&Care.Best quality drugs.Special Internet Prices.No prescription online pharmacy. High quality pills. Order pills online

    Buy:Human Growth Hormone.Lumigan.Petcam (Metacam) Oral Suspension.Actos.100% Pure Okinawan Coral Calcium.Prednisolone.Synthroid.Prevacid.Accutane.Nexium.Mega Hoodia.Retin-A.Zyban.Zovirax.Valtrex.Arimidex….

Leave a Reply

You must be logged in to post a comment.