0
I have an array of 700 objects that are being loaded correctly by PHP, but at the time of sending the answer to the browser with the return $response->withJson()
the following error is shown:
SyntaxError: JSON.parse: end of data when ',' or ']' was expected at line 1 column 181244 of the JSON data
This error occurs precisely when I need to visualize the 700 objects, when I visualize only 30 objects, for example, the Json is generated correctly.
So I was wondering if $response->withJson()
Slim has some character limitation that prevents you from converting this array into a Json. If you have, what would be the best way to view this array in Json format by Slim?
Below is a part of Json that is returned by withJson()
, at the end of the Json ]
was not added by $response->withJson()
:
[
{
"id":"700",
"id_usuario":"1",
"nome":"Empresa 1",
"cnpj":"00.000.000\/0001-00",
"contato":"Teste",
"email":"[email protected]",
"telefone":"(11)00000000",
"cidade":"Santo Andr\u00e9",
"status":"ativado",
"criado_em":"2016-09-14 10:20:22"
},
...
{
"id":"1",
"id_usuario":"1",
"nome":"Empresa 2",
"cnpj":"11.111.111\/0001-11",
"contato":"Teste 2",
"email":"[email protected]",
"telefone":"0000-0000",
"cidade":"",
"status":"ativado",
"criado_em":"2010-12-08 10:20:13"
}
This looks like a JSON formatting error, can you post with 700 elements?? (Edit in your question)
– leofontes
problem is that the error could be anywhere in json, these last 2 objects are correct, so I passed the site that validates json.
– Neuber Oliveira
I cannot put the 700 objects here because each object has more than 10 lines and some contain real information, so I only added the beginning and the end. And it really is formatting problem from what I saw, but it has how to fix it using the
$response->withJson()
slim’s?– Leandro Tabata