on master help sign in
Also define the toEncoding method for the ToJSON instance of Ordering
commit91ec3be856b2457b88afd5ca56d634ae1f71b03b authorBas van Dijk <v.dijk.bas@gmail.com> dateTue 1 Dec 2015, 16:02 (11 years ago) parent811262f
2 files changed+10−4
Data/Aeson/Types/Instances.hs+8−4 changelog.md+2
Data/Aeson/Types/Instances.hs+8−4
@@ -185,10 +185,14 @@ instance FromJSON Bool where
185185 {-# INLINE parseJSON #-}
186186
187187instance ToJSON Ordering where
188− toJSON o = String $ case o of
189− LT -> "LT"
190− EQ -> "EQ"
191− GT -> "GT"
188+ toJSON = toJSON . orderingToText
189+ toEncoding = toEncoding . orderingToText
190+
191+orderingToText :: Ordering -> T.Text
192+orderingToText o = case o of
193+ LT -> "LT"
194+ EQ -> "EQ"
195+ GT -> "GT"
192196
193197instance FromJSON Ordering where
194198 parseJSON = withText "Ordering" $ \s ->
changelog.md+2
@@ -12,6 +12,8 @@
1212
1313* Added ToJSON and FromJSON instances for the Version type.
1414
15+* Added ToJSON and FromJSON instances for the Ordering type.
16+
1517
1618# 0.10.0.0
1719