aboutsummaryrefslogtreecommitdiffstats
path: root/src/Data
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data')
-rw-r--r--src/Data/ByteString/Char8/Extended.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Data/ByteString/Char8/Extended.hs b/src/Data/ByteString/Char8/Extended.hs
index ca0c44a..8bf76c7 100644
--- a/src/Data/ByteString/Char8/Extended.hs
+++ b/src/Data/ByteString/Char8/Extended.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE LambdaCase #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Data.ByteString.Char8.Extended
( module Data.ByteString.Char8
@@ -5,14 +6,16 @@ module Data.ByteString.Char8.Extended
) where
import Data.Aeson
+import Data.Aeson.Types (typeMismatch)
import Data.ByteString.Char8
import Data.Text.Encoding (encodeUtf8)
import Prelude hiding (show)
import qualified Prelude
instance FromJSON ByteString where
- parseJSON (String t) = pure (encodeUtf8 t)
- parseJSON _ = pure undefined
+ parseJSON = \case
+ String t -> pure (encodeUtf8 t)
+ invalid -> typeMismatch "ByteString" invalid
instance FromJSONKey ByteString where
fromJSONKey = FromJSONKeyText encodeUtf8