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

SerializedName based on a property value #716

Closed
JodyLognoul opened this issue Feb 15, 2017 · 5 comments
Closed

SerializedName based on a property value #716

JodyLognoul opened this issue Feb 15, 2017 · 5 comments

Comments

@JodyLognoul
Copy link

Is-it possible to have a serialized_name based on a property value?

@goetas
Copy link
Collaborator

goetas commented Feb 15, 2017

generally no, of course you can set a custom naming strategy and implement it.

as advise, is not recommended to have dynamic naming strategy (means that your model can not be used as specification..)

@JodyLognoul
Copy link
Author

I totally agree...But I have to do it that way. What do you advise me to use to achieve that?

Thanks for your fast reply.

@goetas
Copy link
Collaborator

goetas commented Feb 15, 2017

if you have to do it only for few fields, you can use something as http://stackoverflow.com/questions/41548030/complex-serialization/41552643#41552643

if you have to do it for all the fields in a class, then use a similar approach but using a custom serialization handler.

(with the naming strategy you do not have access to the current object..)

@goetas
Copy link
Collaborator

goetas commented Feb 15, 2017

related to #717

@goetas goetas closed this as completed Feb 15, 2017
@goetas goetas reopened this Feb 15, 2017
@JodyLognoul
Copy link
Author

Thank you, I will try your way or use the handler_callbacks..

@goetas goetas closed this as completed Feb 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants