0
我使用Network.Wreq,Control.Lens,Data.Aeson例外:JSONError “响应的内容类型是” 应用/ random.v4 + JSON “” #Haskell
getInfo = do
let opts = defaults && header "Accept" .~ ["application/random.v4+json"] "Content-Type" .~ ["application/json"]
resp <- asJSON =<< getWith opts "url" :: IO (Response (Map String Value))
let respBody = resp ^. responseBody
return respBody
响应具有Content-Type → application/random.v4+json
当我打电话的功能,它抛出一个异常说
Exception: JSONError "content type of response is \"application/random.v4+json\""
但是,当我拨打电话到API,其响应具有简单Content-Type → application/json
而不是有一些奇特Content-Type → application/random.v4+json
我的功能工作所有预期。当回应contenty-type
更改为application/json
之外的任何内容时,会引发上述错误。
为什么抛出异常?如何使它适用于我的API的所有版本?
**注:API返回的两个版本相同类型的数据。