-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Serializer] Mention adder method to deserialize an array of objects #17956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Serializer] Mention adder method to deserialize an array of objects #17956
Conversation
@@ -1751,6 +1751,61 @@ will be thrown. The type enforcement of the properties can be disabled by settin | |||
the serializer context option ``ObjectNormalizer::DISABLE_TYPE_ENFORCEMENT`` | |||
to ``true``. | |||
|
|||
It is also possible to denormalize an array of object. To do so, ensure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is also possible to denormalize an array of object. To do so, ensure | |
It is also possible to denormalize an array of objects. To do so, ensure |
?
@@ -1751,6 +1751,61 @@ will be thrown. The type enforcement of the properties can be disabled by settin | |||
the serializer context option ``ObjectNormalizer::DISABLE_TYPE_ENFORCEMENT`` | |||
to ``true``. | |||
|
|||
It is also possible to denormalize an array of object. To do so, ensure | |||
the owner object contains a adder method, so the Serializer is able to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the owner object contains a adder method, so the Serializer is able to | |
the owner object contains an adder method, so the Serializer is able to |
@@ -1751,6 +1751,61 @@ will be thrown. The type enforcement of the properties can be disabled by settin | |||
the serializer context option ``ObjectNormalizer::DISABLE_TYPE_ENFORCEMENT`` | |||
to ``true``. | |||
|
|||
It is also possible to denormalize an array of object. To do so, ensure | |||
the owner object contains a adder method, so the Serializer is able to | |||
guess the type of object to denormalize in your collection. Let's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guess the type of object to denormalize in your collection. Let's | |
guess the type of the object to denormalize in your collection. Let's |
It is also possible to denormalize an array of object. To do so, ensure | ||
the owner object contains a adder method, so the Serializer is able to | ||
guess the type of object to denormalize in your collection. Let's | ||
rename ``$inner`` to ``$inners`` and create a adder method:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename ``$inner`` to ``$inners`` and create a adder method:: | |
rename ``$inner`` to ``$inners`` and create an adder method:: |
} | ||
|
||
// This is the key method that will allow the Serializer | ||
// to know the type of object of your collection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// to know the type of object of your collection | |
// to know the type of the object of your collection |
As indicated in #17814, this article is going to be removed. Let's not add more text to it |
Oh yes sorry, I forgot about it. You're right. I think it worth mention it, feel free to take this PR's content if needed 😄 |
After spending a whole day with a colleague to try to deserialize/denormalize an array of objects a few weeks ago without succeeding, I thought that I might share this "adder method" tip to everyone now that I finally found the solution... 😅