{-# OPTIONS_GHC -fno-warn-orphans #-}
module External.Network.HTTP.Types.Method.JSON where
import Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), withText)
import Data.ByteString.Char8 (unpack)
import Data.Text.Encoding (decodeUtf8, encodeUtf8)
import Network.HTTP.Types.Method (StdMethod, parseMethod, renderStdMethod)
instance FromJSON StdMethod where
parseJSON = withText "StdMethod" $ either (fail . unpack) return . parseMethod . encodeUtf8
instance ToJSON StdMethod where
toJSON = toJSON . decodeUtf8 . renderStdMethod