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

More aeson compatibility options #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bsermons
Copy link

@bsermons bsermons commented Jul 7, 2016

Related to #5 and snuck a small fix for #8 for record types.

This adds the options fieldLabelModifier, constructorTagModifier, and untagEnum.

You can see examples of use in the tests but the motivating reason for each was:
fieldLabelModifier: Easy to handle snake_case json formats

constructorTagModifier: Instead of using the full constructor name + namespace, we can now just use the constructor name. eg "Data.Ordering.GT" can just be "GT"

untagEnum: when an sum type contains only simple constructors, it will serialize the values as a string instead of a TaggedObject

test (WrappedRecord { propFoo: "hi", propBAR: 3, order: GT })

where
test :: forall a. Generic a
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please rename this to avoid shadowing?

@paf31
Copy link
Owner

paf31 commented Jul 8, 2016

Looks good so far! Please see my comments above.

@bsermons
Copy link
Author

bsermons commented Jul 8, 2016

Thanks for the comments. I created a PR for purescript-foreign for the TypeMismatch changes.

What do you think about the untagEnums option, could it be named better? I don't think aeson has this because it seems to have that behavior by default, so just named it as I know them.

@paf31
Copy link
Owner

paf31 commented Dec 15, 2016

@bsermons Sorry this got stuck in the pipeline. In future, please do remind me if this happens again.

Would you be interested in porting forward some of these changes in light of #16?

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.

2 participants