summaryrefslogtreecommitdiffstats
path: root/src/Data/Aeson/Extends.hs
blob: d78f81db67c62b2d7734c52f2b75d2064d52a7ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Data.Aeson.Extends (module Data.Aeson.Extends) where

import Data.Aeson as Data.Aeson.Extends

import qualified Data.ByteString.Lazy as LBS
import qualified Data.Text.Encoding.Error as TE
import qualified Data.Text.Lazy.Encoding as LT


eitherDecodeLenient' :: FromJSON a => LBS.ByteString -> Either String a
eitherDecodeLenient' s =
    either (const $ eitherDecode' $ lenientReencode s) id (eitherDecode' s)
  where
    lenientReencode = LT.encodeUtf8 . LT.decodeUtf8With TE.lenientDecode