Skip to content

Commit

Permalink
Export decodeJSON from Data.Binary.Serialise.CBOR.JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgundry committed Jan 20, 2016
1 parent e73c47f commit 9f56d28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Data/API/Value.hs
Expand Up @@ -244,7 +244,7 @@ decode api ty0 = case ty0 of
TyName tn -> decodeDecl api (lookupTyName api tn)
TyList ty -> List <$!> decodeListWith (decode api ty)
TyMaybe ty -> Maybe <$!> decodeMaybeWith (decode api ty)
TyJSON -> JSON <$!> CBOR.decode
TyJSON -> JSON <$!> decodeJSON
TyBasic bt -> decodeBasic bt

decodeBasic :: BasicType -> CBOR.Decoder Value
Expand Down
7 changes: 6 additions & 1 deletion src/Data/Binary/Serialise/CBOR/JSON.hs
Expand Up @@ -3,6 +3,7 @@ module Data.Binary.Serialise.CBOR.JSON (
cborToJson,
jsonToCbor,
encodeJSON,
decodeJSON,
) where

import qualified Data.Aeson as JSON
Expand All @@ -20,6 +21,7 @@ import qualified Data.ByteString.Base64 as Base64
-- import qualified Data.ByteString.Base64.URL as Base64url
import qualified Data.ByteString.Base16 as Base16

import Data.Binary.Serialise.CBOR.Decoding
import Data.Binary.Serialise.CBOR.Encoding
import Data.Binary.Serialise.CBOR.Term as CBOR
import Data.Binary.Serialise.CBOR
Expand All @@ -30,11 +32,14 @@ import Prelude

instance Serialise JSON.Value where
encode = encodeJSON
decode = cborToJson <$> decode
decode = decodeJSON

encodeJSON :: JSON.Value -> Encoding
encodeJSON = encode . jsonToCbor

decodeJSON :: Decoder JSON.Value
decodeJSON = cborToJson <$> decode

-- Most of the types in CBOR have direct analogs in JSON. However, some
-- do not, and someone implementing a CBOR-to-JSON converter has to
-- consider what to do in those cases. The following non-normative
Expand Down

0 comments on commit 9f56d28

Please sign in to comment.