Question

I have a problem with deserializing serialized collection of doctrine collections. Couldn't find docs about that and any topics and I'm new with JMSSerializer. When I try deserialize with:

$collection = $serializer->deserialize($jsonData,'Doctrine\Common\Collections\ArrayCollection','json');

$collection is empty

When I set to null instead of class name I have assoc array on result. Is there an elegant way to deserialize that json?

EDIT: Sorry. Here is serialized collection:

[{"id":88,"name":"Poland","created_at":"2012-09-28T11:59:06+0000"},{"id":90,"name":"Great Britain","created_at":"2012-09-28T11:59:06+0000"}]
Was it helpful?

Solution

Hah! Found what I done wrong :) I gave to deserialize method wrong type. Should be:

$serializer->deserialize($jsonData, 'ArrayCollection<EntityName>', 'json');

and it gave me beatiful array of entities.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top