Answer the question
In order to leave comments, you need to log in
How to implement nested object hierarchy deserialization with Symfony Serializer?
Here is a simplified code example:
class PostsPage
{
/**
* @var MetaPost[]
* @Serializer\Groups({"import_post_page"})
*/
private $posts;
// ...
}
class MetaPost
{
/**
* @var Recommendation
* @Serializer\Groups({"import_post_page"})
*/
private $rec;
/**
* @var Post
* @Serializer\Groups({"import_post_page"})
*/
private $post;
// ...
}
// ...
// Для сокращения количества кода сеттеры и геттеры как и прочие свойства были убраны
$data = $serializer->deserialize($json, 'SomeNamespace\PostsPage', 'json');
$data
will be an instance of the class PostsPage
. But in $posts
it it will just have a multidimensional array, and not an array of type objects MetaPost
(actually, I did not expect a miracle with reading @var
from annotations). Answer the question
In order to leave comments, you need to log in
I think the following couple of links will lead to the right searches
https://github.com/doctrine/DoctrineModule/blob/ma...
https://packagist.org/search/?q=serializer
Symfony's serializer by itself is essentially nothing can. (I mean out of the box performance, like JMS)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question