aeson-utils 0.2.1 → 0.2.1.1
raw patch · 4 files changed
+55/−19 lines, 4 filesdep ~scientificnew-uploader
Dependency ranges changed: scientific
Files
- CHANGELOG.md +5/−0
- README.md +29/−0
- aeson-utils.cabal +19/−15
- src/Data/Aeson/Utils.hs +2/−4
+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Changelog++#### 0.2.1.1++* Allow `scientific 0.3.*`
+ README.md view
@@ -0,0 +1,29 @@+# aeson-utils++[](https://travis-ci.org/silkapp/aeson-utils)++A small package containing helpful addititions to aeson.++It provides `eitherDecodeV` and `decodeV` functions (analogous to `eitherDecode` and `decode` in aeson) that can be used to parse atomic JSON values at the top level. This is not strictly valid JSON, only objects and arrays are allowed at the top level in the specification, but aeson's `encode` allows this already. This gives us the nice property `decodeV . encode = Just`.++The package also contains the `.=?` operator that you can use to optionally construct object pairs:++```haskell+object (+ [ "a" .= foo+ , "b" .= bar+ ] ++ catMaybes+ [ "c" .=? mBaz+ , "d" .=? mQux+ ])+```++Finally it has a `parseNumber` function that converts a scientific into `Either Integer Double` in case you want to distinguish between integrals and fractionals.++## Installation instructions++[aeson-utils is available on hackage](http://hackage.haskell.org/package/aeson-utils)++```+cabal install aeson-utils+```
aeson-utils.cabal view
@@ -1,5 +1,5 @@ name: aeson-utils-version: 0.2.1+version: 0.2.1.1 synopsis: Utilities for working with Aeson. description: Utilities for working with Aeson. license: BSD3@@ -11,20 +11,24 @@ build-type: Simple cabal-version: >=1.10 -library- hs-source-dirs: src- default-language: Haskell2010- ghc-options: -Wall- exposed-modules:- Data.Aeson.Utils- build-depends:- base == 4.*- , aeson >= 0.6 && < 0.8- , attoparsec >= 0.10 && < 0.12- , bytestring >= 0.9 && < 0.11- , scientific == 0.2.*- , text >= 0.11 && < 1.2+extra-source-files:+ CHANGELOG.md+ LICENSE+ README.md source-repository head- type: Git+ type: git location: https://github.com/silkapp/aeson-utils.git++library+ hs-source-dirs: src+ default-language: Haskell2010+ ghc-options: -Wall+ exposed-modules: Data.Aeson.Utils+ build-depends:+ base == 4.*+ , aeson >= 0.6 && < 0.8+ , attoparsec >= 0.10 && < 0.12+ , bytestring >= 0.9 && < 0.11+ , scientific >= 0.2 && < 0.4+ , text >= 0.11 && < 1.2
src/Data/Aeson/Utils.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE CPP #-}- -- | This module provides a few small functions to make working with -- aeson easier. Hopefully at some point they won't be needed anymore. module Data.Aeson.Utils@@ -17,9 +15,9 @@ import Data.Aeson import Data.Aeson.Parser (value) import Data.Aeson.Types-import Data.Scientific-import Data.Text (Text) import Data.Attoparsec.Lazy (Result (..))+import Data.Scientific+import Data.Text (Text) import qualified Data.Attoparsec.Lazy as Atto import qualified Data.ByteString.Lazy as L