SIim withJson () has some character limit to convert an array of objects to Json

0

I have an array with 700 objects that is being loaded correctly by PHP, but at the time of sending the response to the browser with 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 just when I need to view the 700 objects, when I view only 30 objects, for example, Json is generated correctly.

So I wanted to know if Slim's $response->withJson() has some character limitation that prevents it from converting this array to a Json. If so, what would be the best way to view this array in Json format by Slim?

Below is a portion of Json that is returned by withJson() , at the end of 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"
    }
    
asked by anonymous 06.02.2017 / 15:00

1 answer

0

In fact this is a problem in formatting JSON, something left or missing.

I use a website called JSONLint that already points out where the error is, so it's easy to solve.

    
06.02.2017 / 15:29