Copyright | (c) 2019 Felix Paulusma |
---|---|
License | MIT |
Maintainer | felix.paulusma@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
This module contains homonyms of the Data.Aeson library's
encoding and decoding functions that, instead, use
Data.SafeJSON's conversions.
This way, switching from Data.Aeson to Data.SafeJSON is
very easy. After any Data.Aeson imports, just add .Safe
.
It also exports Data.Aeson and Data.SafeJSON itself for
convenience, but still hides parseJSON
and toJSON
so you
will get errors if you use them anywhere. That way you can
explicitly decide where to switch to safeFromJSON
or
safeToJSON
, or keep the current Data.Aeson functions.
Synopsis
- decode :: SafeJSON a => ByteString -> Maybe a
- decode' :: SafeJSON a => ByteString -> Maybe a
- eitherDecode :: SafeJSON a => ByteString -> Either String a
- eitherDecode' :: SafeJSON a => ByteString -> Either String a
- encode :: SafeJSON a => a -> ByteString
- decodeStrict :: SafeJSON a => ByteString -> Maybe a
- decodeStrict' :: SafeJSON a => ByteString -> Maybe a
- eitherDecodeStrict :: SafeJSON a => ByteString -> Either String a
- eitherDecodeStrict' :: SafeJSON a => ByteString -> Either String a
- encodeStrict :: SafeJSON a => a -> ByteString
- decodeFileStrict :: SafeJSON a => FilePath -> IO (Maybe a)
- decodeFileStrict' :: SafeJSON a => FilePath -> IO (Maybe a)
- eitherDecodeFileStrict :: SafeJSON a => FilePath -> IO (Either String a)
- eitherDecodeFileStrict' :: SafeJSON a => FilePath -> IO (Either String a)
- encodeFile :: SafeJSON a => FilePath -> a -> IO ()
Decoding and encoding of SafeJSON types
Lazy ByteString variants
decode :: SafeJSON a => ByteString -> Maybe a Source #
Try to decode a ByteString
to a SafeJSON
value.
decode' :: SafeJSON a => ByteString -> Maybe a Source #
Try to decode a ByteString
to a SafeJSON
value.
eitherDecode :: SafeJSON a => ByteString -> Either String a Source #
Try to decode a ByteString
to a SafeJSON
value.
Produces an error message on failure.
eitherDecode' :: SafeJSON a => ByteString -> Either String a Source #
Try to decode a ByteString
to a SafeJSON
value.
Produces an error message on failure.
encode :: SafeJSON a => a -> ByteString Source #
Encode a SafeJSON
value to a ByteString
.
Strict ByteString variants
decodeStrict :: SafeJSON a => ByteString -> Maybe a Source #
Try to decode a ByteString
to a SafeJSON
value.
decodeStrict' :: SafeJSON a => ByteString -> Maybe a Source #
Try to decode a ByteString
to a SafeJSON
value.
eitherDecodeStrict :: SafeJSON a => ByteString -> Either String a Source #
Try to decode a ByteString
to a SafeJSON
value.
Produces an error message on failure.
eitherDecodeStrict' :: SafeJSON a => ByteString -> Either String a Source #
Try to decode a ByteString
to a SafeJSON
value.
Produces an error message on failure.
encodeStrict :: SafeJSON a => a -> ByteString Source #
Encoding to and decoding from files
decodeFileStrict :: SafeJSON a => FilePath -> IO (Maybe a) Source #
Try to decode a file to a SafeJSON
value.
decodeFileStrict' :: SafeJSON a => FilePath -> IO (Maybe a) Source #
Try to decode a file to a SafeJSON
value.
eitherDecodeFileStrict :: SafeJSON a => FilePath -> IO (Either String a) Source #
Try to decode a file to a SafeJSON
value.
Produces an error message on failure.