I'm writing a data
record to marshall a JIRA
JSON
object. The problem is, multiple objects have the same labels for name/value pairs. For example :
(returned from curl and formatted)
{"expand":"schema,names"
,"startAt":0
,"maxResults":2
,"total":74
,"issues":[
{"expand":"editmeta,renderedFields,transitions,changelog,operations"
,"id":"183614"
,"self":"https://10.64.16.44/rest/api/latest/issue/183614"
,"key":"BNAP-339"
,"fields":{"versions":[
{"self":"https://10.64.16.44/rest/api/2/version/28240"
,"id":"28240"
,"name":"2012-12-07"
,"archived":false
,"released":false
}
]
,"status":{"self":"https://10.64.16.44/rest/api/2/status/1"
,"description":"The issue is open and ready for the assignee to start work on it."
,"iconUrl":"https://10.64.16.44/images/icons/status_open.gif"
,"name":"Open"
,"id":"1"
}
,"description":"Do Re Mi Fa"
,"resolution":null
}
}
]
when I construct the problematic corresponding Haskell data
records I get:
data Issue = Issue {expand :: String
,id :: String
,self :: String
,key :: String
,fields :: Fields
} deriving Generic
data Version = Version {self :: String
,id :: String
,name :: String
,archived :: Bool
,released :: Bool
} deriving Generic
and 'id' and 'self' will clash. It occured to me I could solve this by just changing the names in the records and fixing it with a manually-created FromJSON
instance.
Any alternative solutions would be welcome.