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

Generic _ fieds handling #53

Closed
akaspin opened this issue Dec 17, 2011 · 4 comments

Comments

Projects
None yet
4 participants
@akaspin
Copy link

commented Dec 17, 2011

Example:

data Solid = Solid {
    _id :: String,
    solidStr :: String
} deriving (Show, Eq, Data, Typeable)

solidJson = "{\"_id\":\"a\",\"solidStr\":\"s\"}"

And now big headahe:

decode solidJson :: Maybe Solid

Expect:

Just (Solid {_id = "a", solidStr="s"})

But got:

Nothing

This happens only if _-fields in JSON. But I use aeson for CouchDB. And CouchDB sends "system" fields _id and _rev.

@bos

This comment has been minimized.

Copy link
Owner

commented Dec 21, 2011

This looks nasty. I think @basvandijk introduced the _ mangling - I'd like him to weigh in before I take the pull request.

@basvandijk

This comment has been minimized.

Copy link
Collaborator

commented Dec 21, 2011

This looks nasty. I think @basvandijk introduced the _ mangling

No, I think the _ mangling originally came from the json package. The patch: a1ee5a5 first introduced it.

I'd like him to weigh in before I take the pull request.

I never liked the mangling so I'm OK with removing it.

And if someone really wants to have automatic FromJSON and ToJSON instances with _ mangling she can use
deriveJSON and do the mangling herself.

@EduardSergeev

This comment has been minimized.

Copy link
Contributor

commented Jan 3, 2012

Btw, the above example will work as expected if __id field is used.
The current mangling does look like a hack and should probably be removed but nevertheless it is breaking change. Shouldn't it first go through DEPRECATED pragma stage?
Anyway, I just fixed the broken hack but I have no objections to removing entire hack altogether.

@bos bos closed this in 26ad412 Jan 6, 2012

bos added a commit that referenced this issue Jan 6, 2012

Bump version to 0.6.0.0
This is necessary due to the backwards incompatibility introduced in the fix
for gh-53.

bos added a commit that referenced this issue Jan 6, 2012

@bos

This comment has been minimized.

Copy link
Owner

commented Jan 6, 2012

I'm going to wait a little before releasing 0.6, in case any more bits need fixing.

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

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

Bump version to 0.6.0.0
This is necessary due to the backwards incompatibility introduced in the fix
for bosgh-53.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.