Tuesday, 15 July 2014

json - How can you have two records with the same field names? -



json - How can you have two records with the same field names? -

i'm writing json service jira, , i've come across requirement conflicts haskell's namespace. have record

data assignee = assignee {name :: text} deriving generic instance tojson assignee

this dictated jira wants, unfortunately wants same field different object.

data reporter = reporter {name :: text} deriving generic instance tojson reporter

i see few options:

maybe can circumvent compiler's complaining template haskell, how? i not have reporter record, , alter reporter field seperate service after ticket has been created. know how do, best way?

create json object hand, form record:

info fields = fields { project :: hashmap key project , summary :: text , issuetype :: hashmap name task , versions :: [hashmap name text] , description :: text , assignee :: assignee } deriving (generic)

the thought of making hand gives me wiggins. if must will.

so, question is, if there no other improve way ones i've presented, of these best course of study of action?

the straightforward way enable -xdisambiguaterecordfields extension.

json haskell template-haskell

No comments:

Post a Comment