This is my array to be encoded in PHP:
array (size=1)
0 =>
object(stdClass)[70]
public 'company' => string 'Mc.SUP s. r. o.' (length=15)
public 'fullname' => string ' Jaroslav Antoň' (length=17)
public 'id' => string '1956' (length=4)
public 'editable' => string '1' (length=1)
The string result is:
'[{"company":"Mc.SUP s. r. o.","fullname":" \tJaroslav Anto\u0148","id":"1956","editable":"1"}]'
When trying to use Javascript JSON.parse I got this error message: SyntaxError: JSON.parse: bad control character in string literal at line 1 column 56 of the JSON data
I investigated it and the problematic is \\t .
Does somebody know the easy way how to extra escape it? Something like options in json_encode function. Thanks in advance
The \\t
is an escaped tab character do you really need that character for the fullname
field? You should maybe remove the tab character before doing json_encode
as described here: https://stackoverflow.com/a/17176793/2030937
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.