When trying to parse the below json string with json_decode()
in PHP 5.3 I get error #4 returned which translates to JSON_ERROR_CTRL_CHAR
. Also jsonlint gives me a syntax error: Expecting '{', '['
when manually validating.
How can I reformat this string so it can be parsed?
a:1:{s:18:"test";s:55:"test.pdf";}
Advertisement
Answer
That’s a PHP serialized string, not a JSON.
You may use unserialize
to parse it.
Another thing, the function json_code()
doesn’t exist, you may be talking about the function json_decode()
which transform a json string into a php array