How to have always identifier when serialize ? #5146
Replies: 4 comments
-
With serialization groups, if the children don't have any I think that it'll output that result. See this test and their related entities in our fixtures! |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply. I know what you are talking about (and I use this for my other entities in relations) but here parent entity and children's are the same type, so they have the same serialization group. |
Beta Was this translation helpful? Give feedback.
-
Oh sorry I missed that. There must be a way to do this, a custom normalizer for example or maybe there's something even simpler using the serialization context, not sure rn ^^. |
Beta Was this translation helpful? Give feedback.
-
It is a feature that needs to be introduced in the Symfony Serializer. I came up with a similar example to illustrate the problem: {
"code": "ABC",
"children": [
{
"code": "DEF",
"children": [
{
"code": "JKL",
"children": []
}
]
},
{
"code": "XYZ",
"children": []
}
],
"parent": {
"code": "QRS",
"parent": null
}
} I want to keep traversing down It's not currently possible to have such control over the serialization output. I think we need some kind of property path / "scope" support. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I have a Profile entity with childs and parents :
And when I seriliaze profile I have :
But I don't need any serilization for parents and I just need an IRI :
I finded #1696 which advises to use MaxDepth, but even with a MaxDepth of 1 the parent the parent serializes once.
Maybe I did not understand something, can you help me?
Beta Was this translation helpful? Give feedback.
All reactions