Visitar URL original
Generic _ fieds handling · Issue #53 · haskell/aeson · GitHub
Skip to content

Generic _ fieds handling #53

Closed
Closed

Description

@akaspin

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.

Activity

  1. bos commented on Dec 21, 2011

    @bos
    Collaborator

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

  2. basvandijk commented on Dec 21, 2011

    @basvandijk
    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.

  3. EduardSergeev commented on Jan 3, 2012

    @EduardSergeev
    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.

  4. added 2 commits that reference this issue on Jan 6, 2012
  5. bos commented on Jan 6, 2012

    @bos
    Collaborator

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

  6. added 3 commits that reference this issue on May 18, 2015
    6c4aed4
    417a7ff
    f134d44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions