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
Closed

Generic _ fieds handling #53

akaspin opened this issue Dec 17, 2011 · 4 comments

Comments

@akaspin
Copy link

akaspin 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
Copy link
Collaborator

bos 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
Copy link
Member

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
Copy link
Contributor

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 as completed in 26ad412 Jan 6, 2012
bos added a commit that referenced this issue Jan 6, 2012
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
Copy link
Collaborator

bos 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
This is necessary due to the backwards incompatibility introduced in the fix
for haskellgh-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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants