Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow changes in Aeson 2 #32

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions http2.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Test-Suite hpack
HPACKSpec
JSON
Build-Depends: base >= 4.9 && < 5
, aeson
, aeson >= 2
, base16-bytestring >= 1.0
, bytestring
, directory
Expand All @@ -230,7 +230,7 @@ Test-Suite frame
JSON
Build-Depends: base >= 4.9 && < 5
, Glob >= 0.9
, aeson
, aeson >= 2
, aeson-pretty
, base16-bytestring >= 1.0
, bytestring
Expand Down Expand Up @@ -293,7 +293,7 @@ Executable hpack-encode
Other-Modules: HPACKEncode
JSON
Build-Depends: base >= 4.9 && < 5
, aeson
, aeson >= 2
, aeson-pretty
, array
, base16-bytestring >= 1.0
Expand All @@ -320,7 +320,7 @@ Executable hpack-debug
Other-Modules: HPACKDecode
JSON
Build-Depends: base >= 4.9 && < 5
, aeson
, aeson >= 2
, array
, base16-bytestring >= 1.0
, bytestring
Expand All @@ -345,7 +345,7 @@ Executable hpack-stat
Main-Is: hpack-stat.hs
Other-Modules: JSON
Build-Depends: base >= 4.9 && < 5
, aeson
, aeson >= 2
, aeson-pretty
, array
, bytestring
Expand Down Expand Up @@ -373,7 +373,7 @@ Executable frame-encode
Other-Modules: Case
JSON
Build-Depends: base >= 4.9 && < 5
, aeson
, aeson >= 2
, aeson-pretty
, base16-bytestring >= 1.0
, bytestring
Expand Down
2 changes: 1 addition & 1 deletion test-frame/JSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Data.Aeson.Types
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as B8
import Data.HashMap.Strict (union)
import Data.Aeson.KeyMap (union)
import Data.Maybe (fromJust)
import Data.Text (Text)
import qualified Data.Text as T
Expand Down
7 changes: 4 additions & 3 deletions test-hpack/JSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import Control.Monad (mzero)
import Data.Aeson
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as B8
import qualified Data.HashMap.Strict as H
import qualified Data.Aeson.KeyMap as H
import qualified Data.Aeson.Key as Key
import Data.Text (Text)
import qualified Data.Text as T
import Data.Vector ((!))
Expand Down Expand Up @@ -83,13 +84,13 @@ instance {-# OVERLAPPING #-} FromJSON Header where
parseJSON (Array a) = pure (toKey (a ! 0), toValue (a ! 1)) -- old
where
toKey = toValue
parseJSON (Object o) = pure (textToByteString k, toValue v) -- new
parseJSON (Object o) = pure (textToByteString (Key.toText k), toValue v) -- new
where
(k,v) = head $ H.toList o
parseJSON _ = mzero

instance {-# OVERLAPPING #-} ToJSON Header where
toJSON (k,v) = object [ byteStringToText k .= byteStringToText v ]
toJSON (k,v) = object [ Key.fromText (byteStringToText k) .= byteStringToText v ]

textToByteString :: Text -> ByteString
textToByteString = B8.pack . T.unpack
Expand Down