tags:

views:

37

answers:

1

My string like this:

{
  "key": "value’s",
  "key2": "value"
}

I use json_decode() PHP 5 and class Services_Json for PHP 4 and get nothing when contain "". What is solution?

+3  A: 

Most likely your input string isn't properly utf-8 encoded.

http://docs.php.net/json_decode says:

This function only works with UTF-8 encoded data.
And when I feed it your string utf-8 encoded (i.e. when ’ is encoded as the three-byte-sequence E2 80 99 instead of 92 in latin1) the result is

object(stdClass)#1 (2) {
  ["key"]=>
  string(9) "value’s"
  ["key2"]=>
  string(5) "value"
}

(using php 5.3.3/winxp)

VolkerK
thank for suggestion, my string was saved with ASNI. I have to save with UTF8- without BOM. Now it's working property
Chameron