1

I want to serialize a object in Symfony 3. So I wrote this code:

$serializer = $this->getContainer()->get('jms_serializer');
$context = SerializationContext::create()->enableMaxDepthChecks()->setGroups([...]);
$jsonObject = $serializer->serialize($object, 'json', $context);

The object is of the class Message and includes ManyToOne relations to user and channel (a message belongs to a Channel and to a User). Both values are not null. If I exclude the fields channel and user the serialization succeeded.

In fact the objects Channel and User have various other connections to User, but they are not included in the serialization group. The serialization also fails, if I remove all serialization fields in Channel and User.

How can I solve this? Or how can I check, where my code fails? If you need further information, I'll add it.

mgluesenkamp
  • 529
  • 6
  • 19

0 Answers0