Questions tagged [jsonpath]

JSONPath is a means of using XPath-like syntax to query JSON structures. Not to be confused with rest-assured's JsonPath implementation based on Groovy's Gpath. Use the [json-path-expression] tag for questions about JSON path expressions in general and for questions about JSON path expression DSLs.

JSONPath is a means of using XPath-like syntax to query JSON structures.

It is not a standard, but it does offer a means of querying JavaScript structures directly without needing to convert to or from XML.
JSONPath expressions always refer to a JSON structure in the same way as XPath expression are used in combination with an XML document.

Implementations:

Not to be confused with the standard of the same name by rest-assured: https://github.com/rest-assured/rest-assured/wiki/Usage#json-using-jsonpath

1303 questions
13
votes
3 answers

JsonPath AND Operator on Array

I have an array in JSON and I would like to apply two filters to it like so: $._embedded.values[0]._embedded.data[?(@.var1='value1' && @.var2='value2')] I need to select only those elements from the array that satisfies the AND operation. However,…
Mike Chinaloy
  • 1,336
  • 2
  • 18
  • 40
13
votes
1 answer

Gatling - Looping through JSON array

I have a block of code which needs to loop through a JSON array which is obtained from response of a REST service. (Full gist available here.) .exec(http("Request_1") .post("/endPoint") .headers(headers_1) …
Neil
  • 5,331
  • 13
  • 52
  • 77
12
votes
1 answer

How do I extract multiple values from kubectl with jsonpath

I've found jsonpath examples for testing multiple values but not extracting multiple values. I want to get image and name from kubectl get pods. this gets me name kubectl get pods -o=jsonpath='{.items[*].spec.containers[*].name}' | xargs -n…
navicore
  • 1,601
  • 2
  • 24
  • 43
12
votes
2 answers

How to get the first element when filter in jsonpath?

So I'm working on the below json: { "id": "", "owner": "some dude", "metaData": { "request": { "ref": null, "contacts":[ { "email": null, "name": null, …
Vu Viet Dung
  • 131
  • 1
  • 4
12
votes
3 answers

JsonPath expression to filter using regex

We are using a tool which uses jayway library for evaluating JSONpath expression. Javascript does NOT seem to work with it. How can I use regular expression in the JSONPath in such a case. For instance, in the below example I would like to filter…
sjn
  • 141
  • 1
  • 1
  • 7
11
votes
1 answer

How do you escape the @ symbol in jsonpath?

Given a json list like this: { "listRel:customFieldList": { "platformCore:customField": [ { "@internalId": "801", "scriptId": "custentity_admin_contact_cweb", …
redwards510
  • 1,512
  • 1
  • 13
  • 22
11
votes
4 answers

Matching data in JsonPath with wiremock

I'm trying to create mocks for my login procedure. I use POST method with a couple of fields and login object (with login, password, etc.) For that I'm using JsonPath. Code below: { "request": { "method": "POST", "url": "/login", …
a_dzik
  • 827
  • 2
  • 11
  • 23
11
votes
3 answers

JsonPath: Selecting root level field if satisfies a condition

Given the below Json input: { "category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99 } I need to select the author field if the author matches a given name for eg. Evelyn Waugh. I am struggling to write…
Drona
  • 6,117
  • 1
  • 26
  • 35
11
votes
7 answers

JSONPath Query to get Node-names?

Consider the following piece of JSONPath: { "result":[ { "type":"Residence", "street":"Piazza di Spagna", "city":"-4:0" }, { "type":"Residence", "street":"test", …
Larry
  • 9,699
  • 12
  • 55
  • 81
10
votes
5 answers

AWS step functions and optional parameters

I would like to have a default value for a parameter passed into a step function e.g., "Parameters": { "foo.$": "$.foo" OR "bar" if "$.foo" not specified } is there a way to do this natively with JSONPath or do I have to use a choice + pass…
wrschneider
  • 15,487
  • 10
  • 70
  • 152
10
votes
1 answer

select multiple attributes with jsonpath

I have an array of objects like this one: [ { "id": 192, "name": "Complete name", "username": "nsurname", "state": "active", "created_at": "2016-05-30T07:09:40.981Z", "organization": "", …
mnieto
  • 3,290
  • 3
  • 17
  • 35
10
votes
1 answer

In Python, using jsonpath-rw to get values for specific attribute (json/dict)

Here's my json: { 'test': [ { "id": "1", "description": "Test 1" }, { "id": "2", "description": "Test 2" } ] } I'm trying to get the value for id where description is "Test 1". I found the following example on the JsonPath…
Pavel Chernikov
  • 1,889
  • 1
  • 15
  • 33
10
votes
2 answers

Pick the Nth item from a filter expression in JSONPath

I've been trying to filter a specific element in my JSON using JSONPath and then to choose only the 1st item in the returned array of results. My baisc JSONPath looks something like this: $.store.book[?(@.category==fiction)].price I want to add…
Roy_ro
  • 103
  • 1
  • 4
10
votes
4 answers

JSONPath :contains filter

Hey all, I was wondering if any knew of a way to use a regular expression or wildcard operator (or pehaps '%LIKE%' in SQL) so I could use JSONPath to do searching within a large set of JSON data. For instance (and yes, I'm parsing, not eval( )ing my…
Dan Beam
  • 3,406
  • 2
  • 20
  • 27
10
votes
3 answers

JsonPath - read Java Long type

I've got JSON data that looks like this {"sessionID":7242750700467747000} The number is previously obtained from server response and is generated server-side as Java Long. Client identifies itself thought this sessionID and sends it with requests.…
Wojtek
  • 2,375
  • 5
  • 23
  • 28
1 2
3
86 87