Questions tagged [jayway]
69 questions
5
votes
1 answer
Any reason to start a JsonPath without the "$" dollar sign?
In JsonPath, I've seen the "$" sign described as the symbol that "refers to the root object or element".
Example:
JsonPath.read(json, "$.store.book[*].author");
Question: is there any reason not to start the path with "$"?
In Jayway, you can omit…

Guillaume F.
- 1,010
- 7
- 21
4
votes
1 answer
How to flatten a json with nested lists by Jayway JsonPath?
Currently I need to process some json results based on configuration but not hard code.
For example, with the json as follows
{
data: [{
orderNo: "CG8310150",
details: [{
skuId: 4384,
amount: 2
},…

zyang
- 105
- 1
- 8
3
votes
1 answer
AWS Step Functions: Filter an array using JsonPath
I need to filter an array in my AWS Step Functions state. This seems like something I should easily be able to achieve with JsonPath but I am struggling for some reason.
The state I want to process looks like this:
{
"items": [
{
"id":…

timxyz
- 399
- 2
- 15
3
votes
0 answers
How to select json path dot-notation for path list?
I need to return list of json paths using:
Configuration conf = Configuration.builder()
.options(Option.AS_PATH_LIST).build();
List pathList = using(conf).parse(json).read("$..author");
By default all paths will be in bracket-notation:
…

Anton Savostytskyi
- 178
- 10
3
votes
1 answer
Combine jsonpath expression to read 2 nested properties in JSON string
I am using Slack API (https://slack.com/api/search.messages) to fetch posts in slack channel and parse the posts using Java code.
Following is the sample Slack response where slack posts are 'text' under 'matches' and matches - previous' :
{
…

amit
- 181
- 2
- 4
- 20
3
votes
2 answers
Java - use jsonPath to update Json based on current value
I managed to update a json object using a jsonPath with this code
JSONObject json = new JSONObject("{\"data\":[{\"city\":\"New York\",\"name\":\"John\",\"age\":31},{\"city\":\"Paris\",\"name\":\"Jack\",\"age\":12}]}");
DocumentContext doc =…

Félicien
- 216
- 4
- 16
2
votes
1 answer
How to compare number string in filter operator?
data: [
{
"name": "mark",
"age": "20"
},
{
"name": "john",
"age": "10"
}
]
in this case, how to get age greater than 10?
sample code:
JsonPath.read(json, "$.data[?(@.age > 10)]");

penny
- 43
- 3
2
votes
0 answers
Parsing JSON by json path using circe lib for scala
I am new in scala developing and maybe it's repeated question here, trying to parse json by circe lib, I know how to parse json to get specific value from it but I want to it dynamically by giving json path for any json. For example we have this…

Baktiyar Bekbergen
- 374
- 2
- 4
- 24
1
vote
1 answer
JsonPath is converting colon(:) into equal to(=) while reading each element of an array
I am using "com.jayway.jsonpath" % "json-path" % "2.7.0" for parsing an incoming json message in our API build on akka-http written in scala. The incoming message can have array of records and for each record, some actions will be performed. While…

sam.ban
- 238
- 3
- 13
1
vote
2 answers
jayway library | Reading a JSON from JSONPath
I am using jayway library as I have to use JSONPath Expressions.
{
"fruit":"Apple",
"size":"Large",
"price":"40"
}
Above is my json, now from this JSON suppose I want to read from a specific path.
For Ex: - $.fruit
So the code snippet will be…

agaonsindhe
- 447
- 1
- 5
- 13
1
vote
0 answers
How to get value by Jayway JSONPath if the key shall be case insensitive
I am looking for a JSONPath expression which gets the value for key which is NOT defined strictly, to ignore case sensitivity.
{
"authors":{
"Robert.C.M": "Clean Code",
"Martin.F": "Refactoring"
}
}
So far, I use following…

Lonestar
- 51
- 6
1
vote
1 answer
JSONPath cannot query if condition is a child's property of array
I have a json as below. I want to select list reference of item which has method is "method A". But I cannot query with operator == (with Jayway JSONPath evaluation)
$.items[*].[?(@.methods[*].name == 'method A')].reference
But when I replace…

lantran2019
- 11
- 1
1
vote
1 answer
JsonPath expression involving two root values
I have following JSON, I need to get the personEmailContact which has a matching emailID with emailupdaterequest.emailContact. I tried to write the expression like
$.responsebody[?(@.personEmailContact.emailId…

rsapru
- 688
- 14
- 30
1
vote
0 answers
How to get the Value in the element of JSON by JSONPath?
This is my JSON data
{
"code": 0,
"message": "success",
"data": {
"logFrom": "{\"date_as_long\": 1411455611975}"
}
}
The logFrom object is still a JSON.
In this case, how can I use JSONPath expression to locate date_as_long?

David
- 17
- 3
1
vote
2 answers
Jsonpath: get the value of an element based on its sibling, when the sibiling element is an array containing a specific value
With the following json:
{
"elements": [
{
"ids": [
{
"id": "A"
},
{
"id": "B"
}
],
"value": "one"
},
{
"ids": [
{
"id": "C"
},
…

j.xavier.atero
- 506
- 2
- 10
- 25