I'm using the JMS Serializer. And I found out that the performance is really bad when I use big data. I've the following object structure displayed as an array:
$jsonData = array(
'message' => 'this is a nice message',
'data' => array(
0 => array(
'firstname' => 'achim',
'lastname' => 'menzel'
)
)
);
This is how I serialize the data:
$serializer = $this->get('serializer');
$encodedJson = $serializer->serialize($jsonData, 'json');
$response = new Response($encodedJson);
$response->headers->set('Content-Type', 'application/json');
Data can be a list of 1
till n
objects. When I have more than 500 objects in data, the performance is very very slow (more then 5sec.). When i use json_encode()
directly, it tooks not more then 1 second.
How can I improve the usage of JMS Serializer? I don't think that jms serializer cannot handle big data.
This is the main class which will be used for serializing:
class JsonData {
public $success = false;
public $message = '';
public $data;
public $responseCode = 200;
public $contentType = 'application/json';
}
And currently this object is inside $data
:
class GuestDTO {
private $userid;
private $firstname;
private $lastname;
private $birthday;
private $picturemedium;
private $picturelarge;
private $gender;
private $modifydate;
private $entries = array();
}
And $entries
is a list of objects from this class:
class GuestlistentryDTO extends AbstractGuestDTO{
private $guestlistentryid;
private $guestlistid;
private $arrivedat;
private $bouncername;
private $rejectionreason;
private $companioncount;
private $companioncountcheckin;
private $winner;
private $vip;
}
Without any annotations because I prepared my dto's for using the data as I need.