Skip to content
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] SerializedName based on groups #30483

Open
davidschmidt opened this issue Mar 8, 2019 · 34 comments · May be fixed by #46432 or #58236
Open

[Serializer] SerializedName based on groups #30483

davidschmidt opened this issue Mar 8, 2019 · 34 comments · May be fixed by #46432 or #58236

Comments

@davidschmidt
Copy link

Description
It would be helpful to be able to change the serialized name based on the serialization group.

Example

class Person
{
    /**
     * @SerializedName(name="address1", groups={"registration"})
     * @SerializedName(name="address2", groups={"update"})
     * @Groups({"registration", "update", "view"})
     * @var string
     */
    public $address;
}
@jsamouh
Copy link
Contributor

jsamouh commented Mar 12, 2019

maybe this would be less problematic to change the existing code:

 * @SerializedName({
 *     {"name"="Test1", "groups"={"group1"}},
 *     {"name"="Test2", "groups"={"group2"}},
*     })

@jsamouh
Copy link
Contributor

jsamouh commented Mar 14, 2019

in any case it is difficult to add this feature without break BC... @dunglas wdyt ?

@karatektus
Copy link

Any updates? this would be great :)

@wajihweriemi
Copy link

or alternatives ? maybe ?

@wajihweriemi
Copy link

using getter and setter could be a solution, but it will be a getter and setter for each group

@dunglas
Copy link
Member

dunglas commented Aug 16, 2020

PR welcome, it shouldn't be too hard to implement without BC break (@SerializedName("foo", groups="g")).

@jsamouh
Copy link
Contributor

jsamouh commented Aug 16, 2020

I can try this week end
Should I create a MR with a specific Symfony version ? or shoud I start from master ?

@YaFou
Copy link
Contributor

YaFou commented Aug 16, 2020

@jsamouh it's a new feature so you must start from master.

@jsamouh
Copy link
Contributor

jsamouh commented Aug 17, 2020

Do we agree to use this syntax for annotation ?

 * @SerializedName({
 *     {"name"="Test0"},
 *     {"name"="Test1", "groups"={"group1"}},
 *     {"name"="Test2", "groups"={"group2"}},
 * })

@jsamouh
Copy link
Contributor

jsamouh commented Aug 21, 2020

First try on annotation.

  • Need discussion about the approach (maybe i am totally wrong :-) ) before continuing
  • Miss more tests
  • Missing support for YAML and XML
  • Need your feedback

@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@carsonbot
Copy link

Just a quick reminder to make a comment on this. If I don't hear anything I'll close this.

@davidschmidt
Copy link
Author

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

I would still like to see this.

@carsonbot carsonbot removed the Stalled label Mar 8, 2021
@kniziol
Copy link

kniziol commented Mar 8, 2021

I would still like to see this

Me too

@derrabus
Copy link
Member

derrabus commented Mar 8, 2021

There already was a promising PR by @jsamouh. Maybe someone (or @jsamouh himself) wants to pick that up and resume the work?

@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@carsonbot carsonbot added Stalled and removed Stalled labels Sep 9, 2021
@hafkenscheid
Copy link

Still relevant in my opinion

@BenWaNH
Copy link

BenWaNH commented Sep 17, 2021

It would be nice !

@p-lorenzo
Copy link

Really nice!

@jsamouh
Copy link
Contributor

jsamouh commented Sep 17, 2021

will dot it next week

@jotaseme
Copy link

any update?

@kniziol
Copy link

kniziol commented Oct 19, 2021

will dot it next week

@jsamouh Did you switch week in your calendar? 😉

@SebaGnich
Copy link

Hey guys :) Do you have any news on this?

@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@martinbertinat
Copy link

Yes. It would be awesome to have this.

@carsonbot carsonbot removed the Stalled label Aug 28, 2022
@kniziol
Copy link

kniziol commented Aug 28, 2022

There has not been a lot of activity here for a while. Would you still like to see this feature?

Yes, sir 🙂

@jdflament
Copy link

Yes, it would be awesome.

@xabbuh
Copy link
Member

xabbuh commented Aug 31, 2022

Someone will have to do the actual work for this. It doesn't look like that is the case.

@nicolas-grekas
Copy link
Member

See #46432 ;)

@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@carsonbot
Copy link

Friendly reminder that this issue exists. If I don't hear anything I'll close this.

@carsonbot carsonbot removed the Stalled label Apr 20, 2023
@pauloafonso
Copy link

Hey guys! So glad this feature will be released in 6.3!

And it would also be awesome if serialized_path could be able to be based on groups too! Does anyone agree?

I did a search and didn't find anything related to this.

Thanks!

@haithem-rihane
Copy link

Any update on this ?

@kniziol
Copy link

kniziol commented Jun 8, 2024

Any update on this ?

Please see the #46432 PR mentioned above by @nicolas-grekas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment