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

1786 questions
10
votes
1 answer

jsonpath find string value in the jsonarray independent of array index

I have a Gatling JSON objects of array. The object contains error messages e.g. "error": [ { "errorCode": "111", "errorMessage": "very dynamic error :- at [Source: java.io.PushbackInputStream@5d0edb12; line: 6, column: 6]; nested…
Swapnil Kotwal
  • 5,418
  • 6
  • 48
  • 92
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
  • 2,186
  • 1
  • 20
  • 37
10
votes
1 answer

Check Map key/values with jsonPath

I'm testing a controller that returns a Map @RequestMapping("/") @ResponseBody public Map getMessages(@RequestBody String foo) { Map map = boo.getMap(foo); return map; } Test: ... resultActions …
xedo
  • 1,117
  • 3
  • 18
  • 34
10
votes
3 answers

How to find node exists in JSON

I have following JSON {"subscription": { "callbackReference": "xyz" , "criteria": "Vote", "destinationAddress": "3456" , "notificationFormat" : "JSON" } } I want to check whether "notificationFormat" elements exits there using JSONPath…
Malintha
  • 4,512
  • 9
  • 48
  • 82
9
votes
2 answers

Get name of most recently created pod

In OpenShift, is there a more elegant way of obtaining the name of the most recently created pod in application my_app than this one? name=$(oc get pods -l app=my_app -o=jsonpath='{range.items[*]}{.status.startTime}{"\t"}{.metadata.name}{"\n"}{end}'…
rookie099
  • 2,201
  • 2
  • 26
  • 52
9
votes
1 answer

JSON PATH Field NULL Checking Expression

I have a json array like bellow : { "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95 }, { …
Yassir Arafat Roni
  • 282
  • 1
  • 2
  • 15
9
votes
2 answers

Jsonpath for nested JSON objects

I have a JSON with nested fields: [ { "Platform Parent Dato Id": "23768", "Platform Dato Id": "24138", "Platform Dato Name": "Random Europe", "Platform mission Id": "111112", "Platform submission Id": "638687", …
Datacrawler
  • 2,780
  • 8
  • 46
  • 100
9
votes
4 answers

Parsing JSON using php jsonpath

I'm trying to parse a JSON in PHP using jsonpath .... My JSON is coming from this https://servizionline.sanita.fvg.it/tempiAttesaService/tempiAttesaPs (it's quite too long to cut/paste here but you can see it in a browser session ....) The JSON is…
Cesare
  • 1,629
  • 9
  • 30
  • 72
9
votes
2 answers

How to filter a non-array in JsonPath

Using the following JSON (from http://jsonpath.com): { "firstName": "John", "lastName" : "doe", "age" : 26, "address" : { "streetAddress": "naist street", "city" : "Nara", "postalCode" : "630-0192" }, …
matt_rule
  • 1,220
  • 1
  • 12
  • 23
9
votes
2 answers

Spring testing and JsonPath probblem

I am having an issue with testing and json path I am just trying to perform a simple test and check the value of id: mockMvc.perform(get("/applications/")).andExpect(status().isOk()) .andDo(print()) …
Mike
  • 763
  • 2
  • 12
  • 25
9
votes
1 answer

JSON.Net "Could not read query operator" in SelectTokens

I'm trying to get some info from some JSON I got from magicthegathering.io using the SelectTokens method in JSON.Net. However, when I try to do this I get an error "Could not read query operator". Here's the code I'm using: JToken jtoken =…
The Oddler
  • 6,314
  • 7
  • 51
  • 94
9
votes
3 answers

To print all the paths in a json object

What is the easy way to get all paths in the Given Json Object; For Example: { app:{ profiles:'default' }, application:{ name:'Master Service', id:'server-master' }, server:{ protocol:'http', …
Ysak
  • 2,601
  • 6
  • 29
  • 53
9
votes
2 answers

JSONPath resolver for Java objects

How can I get a value from an Java object instead from a JSON string by applying a JSONPath expression? I receive a Java object that is created from a JSON string (via Jackson, no way to influence it): public class MyJSONInputClass { private…
Sebastian Barth
  • 4,079
  • 7
  • 40
  • 59
9
votes
3 answers

Testing jsonpath that array contains specfic objects in any order

I'm testing a Spring controller which can give back a 400 with field errors. These field errors is an array of objects containing a "path" and "message" field. Now I want to test that some specific call returns multiple errors with specific path and…
Marcel Overdijk
  • 11,041
  • 17
  • 71
  • 110
9
votes
2 answers

Using Gson with a path

Using a simple Json file e.g: {"menu": { "id": "file", "value": "File", "popup": { "menuitem": [ {"value": "New", "onclick": "CreateNewDoc()"}, {"value": "Open", "onclick": "OpenDoc()"}, {"value": "Close", "onclick":…
Eduardo
  • 6,900
  • 17
  • 77
  • 121