Compatibility package between aeson major versions.
This library contains modules named Data.Aeson.VN.M
, which
- Present the same interface as
Data.Aeson.M
as of aesonvN
, and - Compile with all versions of aeson
import Data.Aeson
import qualified Data.Aeson.V2.Key as Key
import qualified Data.Aeson.V2.KeyMap as KeyMap
someExample :: IO ()
someExample = putStrLn
$ unwords
$ map Key.toString
$ KeyMap.keys
$ (\(Object km) -> km)
$ object
[ "hello" .= True
, "world" .= True
]
There are cases where it's not practical to match the aeson functionality exactly when we're making compatibility functions against older (or newer) versions. The following lists concessions we've made.
- Our version of
alterF
(unordered-containers < 0.2.10
) may compute the hash key multiple times, since we don't have access to the internals necessary to pre-compute the key once and use it for any lookup, insert, and delete actions. - We may use strict implementations for should-be lazy functions (or vice
versa). For example, in
unordered-containers < 0.2.11
,foldl = foldl'
andfoldr' = foldr
. - Only one of
coercionToHashMap
orcoercionToMap
will beJust
, depending on your actual aeson version. - Either conversions dealing with
HashMap
or those dealing withMap
will be fast (runtime-erased), depending on your actual aeson version.
stack build --fast --pedantic --test --file-watch