[英]Data.Aeson import Key
我有以下代碼用於從 object 解析 Int。 但無法找到Key
的正確導入。
parseInt :: Object -> Key -> Parser Int
parseInt v field =
asum
[ v .: field,
do
s <- v .: field
case readMaybe s :: Maybe Int of
Nothing -> fail "not a number"
Just x -> return x
]
我努力了
import Data.Aeson
和
import Data.Aeson.Types
但是得到錯誤
Not in scope: type constructor or class ‘Key’
A data constructor of that name is in scope; did you mean DataKinds?
我的 function 中的Key
的正確導入應該是什么?
看起來您正在編寫針對aeson
2.x 的代碼,但您安裝了aeson
要么升級(推薦),要么在此處使用Text
代替Key
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.