on master help sign in
Merge branch 'master' of https://github.com/obsidiansystems/aeson
commit811262f9204ef1a49c6acba1ff5f498c8d6a7ff5 authorBas van Dijk <v.dijk.bas@gmail.com> dateTue 1 Dec 2015, 15:51 (11 years ago) parente17c7fd70e5e34
1 file changed+14
Data/Aeson/Types/Instances.hs+14
Data/Aeson/Types/Instances.hs+14
@@ -184,6 +184,20 @@ instance FromJSON Bool where
184184 parseJSON = withBool "Bool" pure
185185 {-# INLINE parseJSON #-}
186186
187+instance ToJSON Ordering where
188+ toJSON o = String $ case o of
189+ LT -> "LT"
190+ EQ -> "EQ"
191+ GT -> "GT"
192+
193+instance FromJSON Ordering where
194+ parseJSON = withText "Ordering" $ \s ->
195+ case s of
196+ "LT" -> return LT
197+ "EQ" -> return EQ
198+ "GT" -> return GT
199+ _ -> fail "Parsing Ordering value failed: expected \"LT\", \"EQ\", or \"GT\""
200+
187201instance ToJSON () where
188202 toJSON _ = emptyArray
189203 {-# INLINE toJSON #-}