I'm putting together a json in a php function and taking it in js gives me an error when wanting to parse it.
When I validated it on a page, it says it's invalid, by deleting it:
messan "[]"
I can validate it correctly.
Some idea of how to create the json without
messan "[]"
That's my php function and the response it generates.
PHP
$resultado = "[";
foreach($valores as $k=>$v){
$v["X"] = rounded($v["X"]);
$v["Y"] = rounded($v["Y"]);
$v["A"] = rounded($v["A"]);
$v["L"] = rounded($v["L"]);
$v["T"] = rounded($v["T"]);
$resultado .= "{dia:'".$k."',";
$resultado .= "X:'".number_format($v['X'])."',";
$resultado .= "Y:'".number_format($v['Y'])."',";
$resultado .= "A:'".number_format($v['A'])."',";
$resultado .= "L:'".number_format($v['L'])."',";
$resultado .= "T:'".number_format($v['T'])."'},";
}
$resultado = trim($resultado, ",");
$resultado .= "]";
$retorno1 = $resultado;
Respuesta
mesano"[{dia:'01-08-2016',X:'0',Y:'5',A:'38',L:'31',T:'35'}]"