Make derived json instance encode/decode nullary constructor as string. #66

Closed
yihuang opened this Issue Feb 10, 2012 · 1 comment

Comments

Projects
None yet
2 participants

yihuang commented Feb 10, 2012

This can make encoded json of enum-like data type look much better, for example:

data Color = Red | Black | White
encode [Red, Black, White] = "[\"Red\", \"Black\", \"White\"]"

I can make a patch as soon as possible, please tell me what you think.

@yihuang yihuang added a commit to yihuang/aeson that referenced this issue Feb 10, 2012

@yihuang yihuang treat nullary constructor as plain string (fixes #66) b2479ac

@yihuang yihuang added a commit to yihuang/aeson that referenced this issue Feb 10, 2012

@yihuang yihuang better error messages (fixes #66) c7fb177

yihuang commented Feb 10, 2012

The patch for this is added, which included an example for demonstration.

In my project i have several enum-like data type, so this feature is very convenient for me.

basvandijk was assigned Feb 11, 2012

basvandijk closed this in 2dff7be Jan 2, 2013

@tolysz tolysz pushed a commit to tolysz/aeson that referenced this issue May 18, 2015

@basvandijk basvandijk Add support for specifying how to encode datatypes in Data.Aeson.TH
Fixes #68 and fixes #66.
6fbb0c7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment