Page 1 of 1

json_decode and filenames

Posted: Fri Jan 29, 2010 4:17 pm
by jasonlfunk
Hello, I'm having trouble with the json_decode function. Here is some sample code:

Code: Select all

$test = '{"ZTDA5":[["Policy","C:\\files\\1\\Health.pdf"]]}';
$ret = json_decode($test);
var_dump($ret);
 
$ret is always NULL - even though the string I am passing it is valid JSON. Any ideas?

Re: json_decode and filenames

Posted: Fri Jan 29, 2010 5:27 pm
by requinix
Actually, it's not valid. \\ is converted to \ even in single-quoted strings.

$test contains the value

Code: Select all

'{"ZTDA5":[["Policy","C:\files\1\Health.pdf"]]}'
\f, \1, and \H are not valid characters.