summaryrefslogtreecommitdiffstats
path: root/src/Data/ByteString
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/ByteString')
-rw-r--r--src/Data/ByteString/Char8/Extended.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Data/ByteString/Char8/Extended.hs b/src/Data/ByteString/Char8/Extended.hs
new file mode 100644
index 0000000..4d46cd2
--- /dev/null
+++ b/src/Data/ByteString/Char8/Extended.hs
@@ -0,0 +1,15 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+module Data.ByteString.Char8.Extended
+ ( module Data.ByteString.Char8
+ ) where
+
+import Data.Aeson
+import Data.ByteString.Char8
+import Data.Text.Encoding (encodeUtf8)
+
+instance FromJSON ByteString where
+ parseJSON (String t) = pure (encodeUtf8 t)
+ parseJSON _ = pure undefined
+
+instance FromJSONKey ByteString where
+ fromJSONKey = FromJSONKeyText encodeUtf8