I pass php array like
[sit_latitude] => 20° 23.298\' N
inside json_encode(); and output is like,
{\"sit_latitude\":null}
<
json_encode assumes that strings in its input are valid UTF-8 (keep in mind that PHP strings are sequences of bytes, not sequences of Unicode code points). If your text editor is not set to use that encoding (and you haven't manually generated the UTF-8 using hex escape codes such as \xc2\xb0
in a double-quoted string), the string will be encoded as null
(because it is not valid UTF-8).
Other common charsets such as Windows-1252 are also a superset of ASCII, so this is only a problem if there are any non-ASCII characters (U+00B0 DEGREE SIGN included).
Even if the string is valid UTF-8, by default, json_encode will output \u00b0
instead of the actual degree sign. This is not a problem for programmatic decoding using PHP json_decode or JavaScript JSON.parse, which understand JSON hex escape sequences.
(In PHP 5.4, there is a JSON_UNESCAPED_UNICODE
flag to prevent this escaping. However, many web servers still have PHP 5.3 or older, and the flag unescapes even the problematic characters U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR. It is possible to simulate the flag in two lines of code, although as I explained above, you don't have to anyway.)