safe-json-0.1.0: Automatic JSON format versioning

Copyright(c) 2019 Felix Paulusma
LicenseMIT
Maintainerfelix.paulusma@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Data.Aeson.Safe

Contents

Description

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 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

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 #

Same as encode, but also calls toStrict, for convenience.

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.

eitherDecodeFileStrict' :: SafeJSON a => FilePath -> IO (Either String a) Source #

Try to decode a file to a SafeJSON value. Produces an error message on failure.

encodeFile :: SafeJSON a => FilePath -> a -> IO () Source #

Encode a SafeJSON value to a file.