summaryrefslogtreecommitdiffstats
path: root/src/Data/ByteString/Char8/Extended.hs
blob: ca0c44a5f52d1b84743a5ed1368b7c5ee5bf8693 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Data.ByteString.Char8.Extended
    ( module Data.ByteString.Char8
    , show
    ) where

import Data.Aeson
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

instance FromJSONKey ByteString where
  fromJSONKey = FromJSONKeyText encodeUtf8

show :: Show a => a -> ByteString
show = pack . Prelude.show