@@ -12,7 +12,7 @@ import Prelude ()
1212import Prelude.Compat
1313
1414import Data.Aeson
15- (FromJSON , ToJSON (.. ), Value , decode , encode , object , (.=) )
15+ (FromJSON , ToJSON (.. ), Value , decode , encode , object , (.=) , eitherDecode )
1616import Data.ByteString.Char8
1717 (ByteString , append , pack )
1818import qualified Data.ByteString.Lazy as BSL
@@ -219,15 +219,13 @@ spec = describe "Servant.API.ContentTypes" $ do
219219 handleCTypeH (Proxy :: Proxy '[JSONorText ]) " image/jpeg"
220220 " foobar" `shouldBe` (Nothing :: Maybe (Either String Int ))
221221
222- -- aeson >= 0.9 decodes top-level strings
223- describe " eitherDecodeLenient" $ do
222+ describe " eitherDecode is lenient" $ do
224223
224+ -- Since servant-0.20.1 MimeUnrender JSON instance uses eitherDecode,
225+ -- as aeson >= 0.9 supports decoding top-level strings and numbers.
225226 it " parses top-level strings" $ do
226- let toMaybe = either (const Nothing ) Just
227- -- The Left messages differ, so convert to Maybe
228- property $ \ x -> toMaybe (eitherDecodeLenient x)
229- `shouldBe` (decode x :: Maybe String )
230-
227+ property $ \ x -> mimeUnrender (Proxy :: Proxy JSON ) x
228+ `shouldBe` (eitherDecode x :: Either String String )
231229
232230data SomeData = SomeData { record1 :: String , record2 :: Int }
233231 deriving (Generic , Eq , Show )
0 commit comments