我想从 json 对象中提取一个值。我有这个:
post "/test" $ do
a <- jsonBody'
let b = show (a :: Object) -- works well
myVal <- (a :: Object) .: "some_key" -- error
text "test123"
和错误:
• Couldn't match type ‘aeson-1.0.2.1:Data.Aeson.Types.Internal.Parser’
with ‘ActionCtxT () (WebStateM () MySession MyAppState)’
Expected type: ActionCtxT () (WebStateM () MySession MyAppState) a0
Actual type: aeson-1.0.2.1:Data.Aeson.Types.Internal.Parser a0
• In a stmt of a 'do' block:
myVal <- (a :: Aeson.Object) Aeson..: "some_key"
我知道这意味着什么:带有 myVal 的行必须返回 ActionCtxT 类型以及所有其他行。或纯值。因此,如何修复它?