summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraxeman <>2019-07-11 17:51:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-07-11 17:51:00 (GMT)
commit9065b0f6e775e9a3ff40851375fb20ac6075a2ff (patch)
tree794f185f797189694878c801c60392b15a5e57ee
parent68452a4267ae84f17f2bf821999aa7c4e81fbfd9 (diff)
version 0.1.0.1HEAD0.1.0.1master
-rw-r--r--ChangeLog.md10
-rw-r--r--jsonpath.cabal15
-rw-r--r--src/Data/JSONPath/Execute.hs5
-rw-r--r--test/Data/JSONPathSpec.hs5
-rw-r--r--test/resources/json-path-tests/DotOperator.json48
-rw-r--r--test/resources/json-path-tests/FilterExpressionSubscriptOperator.json32
-rw-r--r--test/resources/json-path-tests/IndexedSubscriptOperator.json58
-rw-r--r--test/resources/json-path-tests/SearchOperator.json39
8 files changed, 208 insertions, 4 deletions
diff --git a/ChangeLog.md b/ChangeLog.md
index 9903e21..a7f64af 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -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
diff --git a/jsonpath.cabal b/jsonpath.cabal
index 127a38c..de25627 100644
--- a/jsonpath.cabal
+++ b/jsonpath.cabal
@@ -4,10 +4,10 @@ cabal-version: 1.12
--
-- 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 @@ maintainer: itsakshaymankar@gmail.com
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 @@ library
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 @@ test-suite jsonpath-test
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
diff --git a/src/Data/JSONPath/Execute.hs b/src/Data/JSONPath/Execute.hs
index 6e529cf..53b8692 100644
--- a/src/Data/JSONPath/Execute.hs
+++ b/src/Data/JSONPath/Execute.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
module Data.JSONPath.Execute
(executeJSONPath, executeJSONPathEither, executeJSONPathElement)
where
@@ -9,6 +10,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
diff --git a/test/Data/JSONPathSpec.hs b/test/Data/JSONPathSpec.hs
index fa43c8b..26e4883 100644
--- a/test/Data/JSONPathSpec.hs
+++ b/test/Data/JSONPathSpec.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
@@ -17,6 +18,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
import qualified Data.Vector as V
diff --git a/test/resources/json-path-tests/DotOperator.json b/test/resources/json-path-tests/DotOperator.json
new file mode 100644
index 0000000..135a041
--- /dev/null
+++ b/test/resources/json-path-tests/DotOperator.json
@@ -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
+ ]
+ }
+ ]
+}
diff --git a/test/resources/json-path-tests/FilterExpressionSubscriptOperator.json b/test/resources/json-path-tests/FilterExpressionSubscriptOperator.json
new file mode 100644
index 0000000..c87fda7
--- /dev/null
+++ b/test/resources/json-path-tests/FilterExpressionSubscriptOperator.json
@@ -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"
+ }
+ ]
+ }
+ ]
+}
diff --git a/test/resources/json-path-tests/IndexedSubscriptOperator.json b/test/resources/json-path-tests/IndexedSubscriptOperator.json
new file mode 100644
index 0000000..e3636b5
--- /dev/null
+++ b/test/resources/json-path-tests/IndexedSubscriptOperator.json
@@ -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"]
+ }
+ ]
+}
diff --git a/test/resources/json-path-tests/SearchOperator.json b/test/resources/json-path-tests/SearchOperator.json
new file mode 100644
index 0000000..3dc4458
--- /dev/null
+++ b/test/resources/json-path-tests/SearchOperator.json
@@ -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"]
+ }
+ ]
+}