https://github.com/freckle/aeson-compat
An OSS project providing compatibility modules for aeson
https://github.com/freckle/aeson-compat
terraform-managed
Last synced: 11 months ago
JSON representation
An OSS project providing compatibility modules for aeson
- Host: GitHub
- URL: https://github.com/freckle/aeson-compat
- Owner: freckle
- License: mit
- Created: 2025-01-06T17:40:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-22T18:58:00.000Z (over 1 year ago)
- Last Synced: 2025-01-22T19:42:10.610Z (over 1 year ago)
- Topics: terraform-managed
- Language: Haskell
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.lhs
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# aeson-compat
[](https://hackage.haskell.org/package/aeson-compat)
[](http://stackage.org/nightly/package/aeson-compat)
[](http://stackage.org/lts/package/aeson-compat)
[](https://github.com/freckle/aeson-compat/actions/workflows/ci.yml)
Compatibility package between aeson major versions.
## Organization
This library contains modules named `Data.Aeson.VN.M`, which
1. Present the same interface as `Data.Aeson.M` as of aeson `vN`, and
2. Compile with all versions of aeson
## Example
```haskell
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
]
```
## Gotchas
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'` and
`foldr' = foldr`.
- Only one of `coercionToHashMap` or `coercionToMap` will be `Just`, depending
on your actual aeson version.
- Either conversions dealing with `HashMap` or those dealing with `Map` will be
fast (runtime-erased), depending on your actual aeson version.
## Development & Tests
```console
stack build --fast --pedantic --test --file-watch
```
---
[CHANGELOG](./CHANGELOG.md) | [LICENSE](./LICENSE)