0

I have developed a web application using Zend Framework version 2.8 few months ago and i use json serialization to retrieve data from my database.

So heres the problem : I have just open again the project few days agos and i have noticed that the json serialization didn't work anymore in some cases.

For example, if i do some basic json serialization like that it works great :

        $test = array();
        array_push($test,["test" => 1]);
        array_push($test,["test" => 2]);
        array_push($test,["test" => 3]);
        array_push($test,["test" => 4]);
        array_push($test,["test" => 5]);
        return $this->getResponse()->setContent(Json::encode($test));
//[{"test":1},{"test":2},{"test":3},{"test":4},{"test":5}] works!

But when i serialize to json with more datas from my database, nothing is displayed, like for example with this request :

        foreach ($results as $activite) {
            array_push($activitesTab,$activite);
        }
var_dump($activitesTab) // $activitesTab is an array of the records of my db and i'm sure that it's not empty 
        return $this->getResponse()->setContent(Json::encode($activitesTab));

I don't understand why nothing is displayed, size limit maybe ? But i don't think that is the problem because i want to serialize "just" 100 records from the db.

If someone got an idea, it will be great for me to understand why i have this problem.

Thanks in advance

2
  • Don't you have any errors in php.log file? Any time limit? Memory size? What is Http status code of that response? Commented Dec 25, 2020 at 21:05
  • I have since solved my problem, if i remember well, that was an encoding issue because i had some datas with accents which wasn't encoded correctly. Commented Dec 28, 2020 at 8:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.