jsonpath 0.1.0.0 → 0.1.0.1
raw patch · 8 files changed
+208/−4 lines, 8 filesdep ~aesondep ~attoparsecdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson, attoparsec, base, text, unordered-containers, vector
API changes (from Hackage documentation)
Files
- ChangeLog.md +10/−0
- jsonpath.cabal +11/−4
- src/Data/JSONPath/Execute.hs +5/−0
- test/Data/JSONPathSpec.hs +5/−0
- test/resources/json-path-tests/DotOperator.json +48/−0
- test/resources/json-path-tests/FilterExpressionSubscriptOperator.json +32/−0
- test/resources/json-path-tests/IndexedSubscriptOperator.json +58/−0
- test/resources/json-path-tests/SearchOperator.json +39/−0
ChangeLog.md view
@@ -1,3 +1,13 @@ # Changelog for jsonpath-hs +## v0.1.0.1++* Import Data.Semigroup to support GHC 8+* Add test json files to make sure test sdist compile and runs++## v0.1.0.0++* Start the project++ ## Unreleased changes
jsonpath.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: fabb3215a8083837cad56530f0576cfca0cb5d7f685b839c26adcf1f3eb129ab+-- hash: 4b5596942f26fb29d7787297913412686621fb6005a9a529e6e99af0e451773e name: jsonpath-version: 0.1.0.0+version: 0.1.0.1 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,10 +18,15 @@ 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.4 build-type: Simple extra-source-files: README.md ChangeLog.md+ test/resources/json-path-tests/DotOperator.json+ test/resources/json-path-tests/FilterExpressionSubscriptOperator.json+ test/resources/json-path-tests/IndexedSubscriptOperator.json+ test/resources/json-path-tests/SearchOperator.json source-repository head type: git@@ -41,7 +46,7 @@ build-depends: aeson >=1.4.2 && <1.5 , attoparsec >=0.13.2 && <0.14- , base >=4.7 && <5+ , base >=4.9 && <5 , text >=1.2.3 && <1.3 , unordered-containers >=0.2.10 && <0.3 , vector >=0.12.0 && <0.13@@ -56,11 +61,13 @@ hs-source-dirs: test ghc-options: -threaded -rtsopts -with-rtsopts=-N+ build-tool-depends:+ hspec-discover:hspec-discover build-depends: aeson >=1.4.2 && <1.5 , aeson-casing , attoparsec >=0.13.2 && <0.14- , base >=4.7 && <5+ , base >=4.9 && <5 , bytestring , file-embed , hspec
src/Data/JSONPath/Execute.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} module Data.JSONPath.Execute (executeJSONPath, executeJSONPathEither, executeJSONPathElement) where@@ -8,6 +9,10 @@ import Data.HashMap.Strict as Map import Data.JSONPath.Types import Data.Text (unpack)++#if !MIN_VERSION_base (4,11,0)+import Data.Semigroup ((<>))+#endif import qualified Data.Text.Lazy as LazyText import qualified Data.Vector as V
test/Data/JSONPathSpec.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-}@@ -16,6 +17,10 @@ import GHC.Generics import Test.Hspec import Test.Hspec.Attoparsec++#if !MIN_VERSION_base (4,11,0)+import Data.Semigroup ((<>))+#endif import qualified Data.ByteString.Lazy as LBS import qualified Data.Text.Lazy as LazyText
+ test/resources/json-path-tests/DotOperator.json view
@@ -0,0 +1,48 @@+{ + "title": "Dot Operator", + "data": { + "firstName": "John", + "lastName": "Doe", + "home": "987-654-3210", + "mobile": null + }, + "tests": [ + { + "path": "$.firstName", + "result": [ + "John" + ] + }, + { + "path": "$.lastName", + "result": [ + "Doe" + ] + }, + { + "path": "$.home", + "result": [ + "987-654-3210" + ] + }, + { + "path": "$.mobile", + "result": [ + null + ] + }, + { + "path": "$.missingKey", + "result": false + }, + { + "path": "$.*", + "result": [ + "John", + "Doe", + "987-654-3210", + null + ] + } + ] +}
+ test/resources/json-path-tests/FilterExpressionSubscriptOperator.json view
@@ -0,0 +1,32 @@+{ + "title" : "Filter Expression Subscript Operator", + "data" : [4, + "string", + false, + [1, 2, 3], { + "index" : 1, + "name" : "John Doe", + "occupation" : "Architect" + }, { + "index" : 2, + "name" : "Jane Smith", + "occupation" : "Architect", + "color" : "blue" + } + ], + "tests" : [{ + "path" : "$[?(@.occupation == \"Architect\")]", + "result" : [{ + "index" : 1, + "name" : "John Doe", + "occupation" : "Architect" + }, { + "index" : 2, + "name" : "Jane Smith", + "occupation" : "Architect", + "color" : "blue" + } + ] + } + ] +}
+ test/resources/json-path-tests/IndexedSubscriptOperator.json view
@@ -0,0 +1,58 @@+{ + "title" : "Indexed Subscript Operator", + "data" : [ + "John Doe", + 36, + "Architect", + "one", + "three", + "five" + ], + "tests" : [{ + "path" : "$[2]", + "result" : ["Architect"] + }, { + "path" : "$[-1]", + "result" : ["five"] + }, { + "path" : "$[10]", + "result" : false + }, { + "path" : "$[1:4]", + "result" : [36, "Architect", "one"] + }, { + "path" : "$[1:4:2]", + "result" : [36, "one"] + }, { + "path" : "$[:4:2]", + "result" : ["John Doe", "Architect"] + }, { + "path" : "$[1::2]", + "result" : [36, "one", "five"] + }, { + "path" : "$[::2]", + "result" : ["John Doe", "Architect", "three"] + }, { + "path" : "$[1:]", + "result" : [36, "Architect", "one", "three", "five"] + }, { + "path" : "$[:3]", + "result" : ["John Doe", 36, "Architect"] + }, { + "path" : "$[0,3]", + "result" : ["John Doe", "one"] + }, { + "path" : "$[0,1::2]", + "result" : ["John Doe", 36, "one", "five"] + }, { + "path" : "$[0:2,4:6]", + "result" : ["John Doe", 36, "three", "five"] + }, { + "path" : "$[0:2,4]", + "result" : ["John Doe", 36, "three"] + }, { + "path" : "$[*]", + "result" : ["John Doe", 36, "Architect", "one", "three", "five"] + } + ] +}
+ test/resources/json-path-tests/SearchOperator.json view
@@ -0,0 +1,39 @@+{ + "title" : "Search Operator", + "data" : { + "firstName" : "John", + "lastName" : "Doe", + "eyes" : "blue", + "children" : [{ + "firstName" : "Sally", + "lastName" : "Doe", + "favoriteGames" : ["Halo", "Minecraft", "Lego: Star Wars"] + }, { + "firstName" : "Mike", + "lastName" : "Doe", + "eyes" : "green" + } + ] + }, + "tests" : [{ + "path" : "$..firstName", + "result" : ["John", "Sally", "Mike"] + }, { + "path" : "$..lastName", + "result" : ["Doe", "Doe", "Doe"] + }, { + "path" : "$..eyes", + "result" : ["blue", "green"] + }, { + "path" : "$..missingKey", + "result" : false + }, { + "path" : "$..[1]", + "result" : [{ + "firstName" : "Mike", + "lastName" : "Doe", + "eyes" : "green" + }, "Minecraft"] + } + ] +}