在Aeson JSON库中,点等号(
.=
)和点冒号(.:
)语法在这个例子中代表什么意思?instance ToJSON Coord where
toJSON (Coord xV yV) = object [ "x" .= xV,
"y" .= yV ]
-- A FromJSON instance allows us to decode a value from JSON. This
-- should match the format used by the ToJSON instance.
instance FromJSON Coord where
parseJSON (Object v) = Coord <$>
v .: "x" <*>
v .: "y"
parseJSON _ = empty
Github上提供了完整示例:https://github.com/bos/aeson/blob/master/examples/Simplest.hs
aeson
库的函数。欲了解更多详细信息,请查看此链接:http://hackage.haskell.org/package/aeson-0.7.0.3/docs/Data-Aeson.html - Sibi(.:)
和(.=)
。 - hammar