As title says, I have a problem with JMS serializer running on Symfony 2.7 which returns a malformed JSON. This happens only when database becomes bigger.
I made a simple function which returns the whole database serialized in JSON, sometimes is useful for me to check some data.
Basically I have this function
function asJson($serializationGroup = null)
{
$serializer = SerializerBuilder::create()->build();
$serGroups = array('Default');
if (is_string($serializationGroup)) {
$serGroups[] = $serializationGroup;
}
if (is_array($serializationGroup)) {
foreach($serializationGroup as $sg) $serGroups[] = $sg;
}
$serializationContext = SerializationContext::create()->setGroups($serGroups);
$serializationContext->setSerializeNull(true);
return $serializer->serialize($this, 'json', $serializationContext);
}
which returns a JSON containing data associated to given serialization groups. Then I call it from a Controller giving all my serialization groups in order to serialize the entire db.
But, as I said, when my db becomes bigger I get a malformed JSON. Moreover the error is always different
SyntaxError: JSON.parse: expected ':' after property name in object at line 1 column 182085 of the JSON data
SyntaxError: JSON.parse: expected ',' or '}' after property value in object at line 1 column 367466 of the JSON data
SyntaxError: JSON.parse: expected ':' after property name in object at line 1 column 1158 of the JSON data
I tried to analyze the JSON and I noticed that it is totally corrupted after the error line.. Something like:
"commands_deletedse," <-- here starts the error, the rest is malformed
active ":true,"
readonly ":false,"
running ":false,"
...
UPDATE
It seems to work on another PC having MySQL 5.7 while the bug is present on another PC having MySQL 5.5. I don't know if it has something to do with..
UPDATE 2
It seems to work on the same PC but from Symfony command, hence I would say it has something to do with nginx configuration. In fact I even noticed that calling it from website works 1/10 time, so I would say the error comes from something like a timeout configuration or so. I use nginx + php-fpm.
UPDATE 3
I tried to starting the Symfony internal webserver and then call the controller function but I got the same error. I'm starting have no idea about what should I test..
Any thought?