From 2842e05c232505c670daee0fffb9a34d5c866217 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 21 Jan 2019 19:14:55 +0100 Subject: src: add Data.ByteString.Char8.Extended --- src/Data/ByteString/Char8/Extended.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/Data/ByteString/Char8/Extended.hs (limited to 'src/Data/ByteString') 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 -- cgit v1.2.3