Skip to content

rename fields from JSON deserialization #150

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

Closed
zoechi opened this issue Mar 17, 2017 · 5 comments
Closed

rename fields from JSON deserialization #150

zoechi opened this issue Mar 17, 2017 · 5 comments

Comments

@zoechi
Copy link
Contributor

zoechi commented Mar 17, 2017

I have to deserialize JSON that contains case as field name which is a reserved word in Dart and therefore I can't use that as field name in a built_value class.

Is a custom serializer like explained in #134 (comment) a possible approach to solve that, or is there something better?

@davidmorgan
Copy link
Collaborator

It should work to rename fields using a serializer plugin, as in this request to support renaming enum values:

#144

Please let me know if that works. It would make sense to have standard plugins for doing this be part of built_value.

@zoechi
Copy link
Contributor Author

zoechi commented Mar 17, 2017

Great! Yes, a standard way would be great.
Perhaps some field decorator and a way to get it's value during deserialization.
I'll try the custom serializer for now.

@zoechi
Copy link
Contributor Author

zoechi commented Mar 23, 2017

I created a plugin for that and it's working fine.
Not even sure anymore if it really needs a standard plugin. Perhaps a plugin example, like the one from #144 would be enough.

@davidmorgan
Copy link
Collaborator

Thanks! Probably we need at least a set of examples, yes. I'll leave this issue open for that.

@davidmorgan
Copy link
Collaborator

I'm going to merge into #144.

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