Hi,
I am trying to use the "in" filter on a json to check if the values in the list are present in the json array or not, however i am getting exception on this, please see the following json data and the jsonpath expression.
Json Data
{
"Books": {
"History": [
{
"badge": "y",
"Tags": [
"Indian",
"Culture"
],
"ISBN": "xxxxxxx",
"id": 1,
"name": "Cultures in India"
},
{
"badge": "y",
"Tags": [
"Pre-historic",
"Creatures"
],
"ISBN": "xxxxxxx",
"id": 1,
"name": "Pre-historic Ages"
}
]
}
}
The expression which i am trying to run is,
$.Books.History[?(@.Tags in ['Indian','Culture'])]
This is giving the following exceptioncom.jayway.jsonpath.InvalidPathException: com.jayway.jsonpath.InvalidPathException: com.jayway.jsonpath.InvalidPathException: Space not allowed in path
at com.jayway.jsonpath.internal.PathCompiler.compile(PathCompiler.java:157)
at com.jayway.jsonpath.JsonPath.<init>(JsonPath.java:99)
at com.jayway.jsonpath.JsonPath.compile(JsonPath.java:426)
at com.jayway.jsonpath.internal.JsonReader.read(JsonReader.java:135)
at com.lb.spark.dataanalytics.test.TestJsonPath.main(TestJsonPath.java:65)
Caused by: com.jayway.jsonpath.InvalidPathException: com.jayway.jsonpath.InvalidPathException: Space not allowed in path
at com.jayway.jsonpath.internal.PathCompiler.compile(PathCompiler.java:157)
at com.jayway.jsonpath.Criteria.create(Criteria.java:778)
at com.jayway.jsonpath.Criteria.parse(Criteria.java:755)
at com.jayway.jsonpath.Filter.parse(Filter.java:175)
at com.jayway.jsonpath.internal.PathCompiler$PathComponentAnalyzer.analyzeCriteriaSequence4(PathCompiler.java:284)
at com.jayway.jsonpath.internal.PathCompiler$PathComponentAnalyzer.analyze(PathCompiler.java:262)
at com.jayway.jsonpath.internal.PathCompiler$PathComponentAnalyzer.analyze(PathCompiler.java:236)
at com.jayway.jsonpath.internal.PathCompiler.compile(PathCompiler.java:145)
... 4 more
Caused by: com.jayway.jsonpath.InvalidPathException: Space not allowed in path
at com.jayway.jsonpath.internal.PathCompiler.compile(PathCompiler.java:100)
... 11 more
I am trying to do, is to find if a list of elements are present in the json array or not.
Also i wasn't able to find any examples on "in" filter.
Please help me out on this.
Regards,
Harshit