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

[WIP] Ability to transform the keys #60

Closed
wants to merge 1 commit into from

Conversation

joshprice
Copy link

This is an attempt at solving #44.

Syntax is as follows:

iex(1)> Poison.decode ~s({"fooBar": 1}), key_transformer: Poison.SnakeCase
{:ok, %{"foo_bar" => 1}}

iex(2)> Poison.encode %{foo_bar: 1}, key_transformer: Poison.CamelCase     
{:ok, "{\"fooBar\":1}"}

This probably kills performance, and needs some macros to fix it. However it's here as a working proposal for further discussion.

It's also likely that modifying Poison to do this is not as useful as making it a transformation step in the process. Similar to the comments in #55 this might be better done in a separate library.

Fixes #44.

Paired with @Bockit

@joshprice
Copy link
Author

Build failing because Macro.* are 1.2 only

@devinus
Copy link
Owner

devinus commented Jan 24, 2016

@joshprice Yeah, this would undeniably slow things down a lot. I'm thinking of alternative ways to do this.

@joshprice
Copy link
Author

I'm going to close this on the basis that it isn't a great idea. Feel free to reopen if you disagree.

@joshprice joshprice closed this Feb 14, 2016
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

Successfully merging this pull request may close these issues.

Possibility of adding options for manipulating key names
2 participants