packages feed

jsonpath 0.2.0.0 → 0.2.1.0

raw patch · 4 files changed

+13/−19 lines, 4 filesdep ~aesonPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: aeson

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for jsonpath-hs +## v0.2.1.0++* Support and require aeson >= 2+ ## v0.2.0.0  * BreakingChange: Fix typo in `BeginningPoint`.
README.md view
@@ -1,9 +1,5 @@ # jsonpath-hs ---[![Build Status](https://travis-ci.org/akshaymankar/jsonpath-hs.svg?branch=master)](https://travis-ci.org/akshaymankar/jsonpath-hs) [![Matrix Build](https://matrix.hackage.haskell.org/api/v2/packages/jsonpath/badge)](https://matrix.hackage.haskell.org/package/jsonpath)- Implementation of jsonpath as [described by Steffen Göessner](https://goessner.net/articles/JsonPath/).  ## State of this library
jsonpath.cabal view
@@ -1,13 +1,7 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.2.------ see: https://github.com/sol/hpack------ hash: 4d0aa69594f07e7d4fcd3167a3479d8c56427dab956b8dfc48e86323ade6adf7- name:           jsonpath-version:        0.2.0.0+version:        0.2.1.0 synopsis:       Library to parse and execute JSONPath description:    Please see the README on GitHub at <https://github.com/akshaymankar/jsonpath-hs#readme> category:       Text, Web, JSON@@ -18,7 +12,6 @@ copyright:      Akshay Mankar license:        BSD3 license-file:   LICENSE-tested-with:    GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5 build-type:     Simple extra-source-files:     README.md@@ -44,7 +37,7 @@   hs-source-dirs:       src   build-depends:-      aeson >=1.1+      aeson >=2     , attoparsec >=0.13     , base >=4.9 && <5     , text >=1.2
src/Data/JSONPath/Execute.hs view
@@ -6,7 +6,8 @@ import Data.Aeson import Data.Aeson.Text import Data.Function       ((&))-import Data.HashMap.Strict as Map+import qualified Data.Aeson.KeyMap as Map+import qualified Data.Aeson.Key as Key import Data.JSONPath.Types import Data.Text           (unpack) @@ -28,12 +29,12 @@ executeJSONPathElement :: JSONPathElement -> Value -> ExecutionResult Value executeJSONPathElement (KeyChild key) val =   case val of-    Object o -> Map.lookup key o-                & (maybeToResult (notFoundErr key o))+    Object o -> Map.lookup (Key.fromText key) o+                & maybeToResult (notFoundErr key o)     _ -> ResultError $ expectedObjectErr val-executeJSONPathElement (AnyChild) val =+executeJSONPathElement AnyChild val =   case val of-    Object o -> ResultList $ Map.elems o+    Object o -> ResultList . map snd $ Map.toList o     Array a  -> ResultList $ V.toList a     _        -> ResultError $ expectedObjectErr val executeJSONPathElement (Slice slice) val =@@ -63,7 +64,7 @@      else ResultList $ x ++ y  valMap :: ToJSON b => (Value -> ExecutionResult b) -> Value -> [ExecutionResult b]-valMap f v@(Object o) = elems $ Map.map f o+valMap f v@(Object o) = map snd . Map.toList $ Map.map f o valMap f (Array a) = V.toList $ V.map f a valMap _ v = pure $ ResultError $ "Expected object or array, found " <> (encodeJSONToString v)