json_decode () devuelve en blanco pero es json válido

$a = '[{"function":"error_handler","class":"LP","type":"::","args":[256,"Call to undefined method LP_pdo::get_rorzxx() on D:\\MARK\\htdocs\\lessphptest\\application\\controllers\\users.php (23)","D:\\MARK\\htdocs\\lessphp\\LP.php",210,{"e":{"type":1,"message":"Call to undefined method LP_pdo::get_rorzxx()","file":"D:\\MARK\\htdocs\\lessphptest\\application\\controllers\\users.php","line":23}}]},{"file":"D:\\MARK\\htdocs\\lessphp\\LP.php","line":210,"function":"trigger_error","args":["Call to undefined method LP_pdo::get_rorzxx() on D:\\MARK\\htdocs\\lessphptest\\application\\controllers\\users.php (23)",256]},{"function":"shutdown","class":"LP","type":"::","args":[]}]';
$a = json_decode($a);
print_r($a);

echo json_last_error();

print_r() returns blank.

json_last_error() returns 4 which is JSON_ERROR_SYNTAX

But, when I run the json string in http://jsonlint.com/ vuelve Valid JSON

Cualquier idea por qué?

preguntado el 31 de julio de 12 a las 12:07

try: $b = array(); $b = json_decode($a,true); this should convert the json into an associative array, but you first gotta declare $b = array(); -

2 Respuestas

Necesitas escapar de tu \ once for PHP and once again for JSON

D:\\\\....

Respondido 31 Jul 12, 12:07

surely you mean escape your \ rather than / - jon taylor

that works, but is there a function that does that? I just find/replace in Notepad :-) - IMB

@IMB PHP has excellent find/replace capabilities, too! $str = str_replace('\', '\\', $str); ;-)- kaii

Try to set encoding to utf-8...did the job for me

Respondido 31 Jul 12, 12:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.