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
6
votes
1 answer

Using JSONPath to filter properties in JSON documents

I have an arbitrarily defined JSON document, and I want to be able to apply a JSONPath expression like a whitelist filter for properties: All selected nodes and their ancestors back to the root node remain, all other nodes are removed. If the nodes…
pcdev
  • 2,852
  • 2
  • 23
  • 39
6
votes
1 answer

Is there any proper matcher to parse and compare LocalDateTime field in Json response from MockMvc

I'm testing get method of my SpringBoot controller, which is providing objects, written in base in particular time range. I realize that I can get json after mockMvc performing and parse it with object mapper, use some streams and one assert, but I…
Ludov Dmitrii
  • 425
  • 5
  • 9
6
votes
2 answers

JSON Path String Evaluation of root value

Have a service that returns a very basic json respons: { "methodresult": "error", "ErrorCode": 2, "ErrorCodeText": "format", "ErrorMessage": "Json parse exception at pos:171 msg:Expecting \"key\"" } And am trying to use JSONPath to…
GAG
  • 111
  • 4
6
votes
1 answer

EvaluateJsonPath unable to return a scalar

I'm trying to extract a value from JSON to a flowfile-attribute. When I run the EvaluateJsonPath processor I get an error stating "Unable to get a scalar value for expression $..fields.storyBoard.stringValue. Input JSON looks like this: { "name"…
rennyB
  • 143
  • 3
  • 10
6
votes
3 answers

Functions min(), max() or sum() with jsonpath

According to JsonPath on GitHub it shall be possible to access max(), min() or the sum() of an array but I dont know how. With this exampledata: { "store": { "book": [ { "category": "reference", "author": "Nigel Rees", …
smaica
  • 723
  • 2
  • 11
  • 26
6
votes
2 answers

Parse JSON using Spring SPEL

Can someone tell me why this does not work: @Test public void should_parse_json() { Expression expression = new SpelExpressionParser().parseExpression("#jsonPath(get('JsonData'), '$.someData')"); Map data = new HashMap<>(); …
elBastarde
  • 185
  • 3
  • 8
6
votes
2 answers

Java JsonPath: Extract nested json object as string

I need to get a json string, that is part of a larger json. As a simplified example, I want to extract only file01, and I need the json object as a string. { "file01": { "id": "0001" }, "file02": { "id": "0002" …
Jonas_Hess
  • 1,874
  • 1
  • 22
  • 32
6
votes
1 answer

AWS Glue Custom Classifiers Json Path

I have a set of Json data files that look like this [ {"client":"toys", "filename":"toy1.csv", "file_row_number":1, "secondary_db_index":"4050", "processed_timestamp":1535004075, "processed_datetime":"2018-08-23T06:01:15+0000", …
itsjpv
  • 63
  • 1
  • 1
  • 4
6
votes
1 answer

Pass multiple InputPaths to a StepFunctions Task

While invoking a state's task, is it possible to specify multiple InputPaths, or 'pick' more than one JSON nodes to be passed to the task's input ? Example: If this is the execution input: { "id":"identifier", "nestedObjectA": { …
6
votes
1 answer

What's the correct JsonPath expression to search a JSON root object using Newtonsoft.Json.NET?

Most examples deal with the book store example from Stefan Gössner, however I'm struggling to define the correct JsonPath expression for a simple object (no array): { "Id": 1, "Name": "Test" } To check if this json contains Id = 1. I tried the…
Stef Heyenrath
  • 9,335
  • 12
  • 66
  • 121
6
votes
10 answers

How to get the status of a particular pod or container : kubectl get pods using jsonpath

I have this JSON output from Kubernetes and got it from kubectl get pods -o jsonpath={.items[*]} { "apiVersion": "v1", "items": [ { "apiVersion": "v1", "kind": "Pod", …
bherto39
  • 1,516
  • 3
  • 14
  • 29
6
votes
3 answers

Extract json in an array in Jmeter

How do I extract the json object name from the below json data in Jmeter [ : { : : "name":"x", : : "age":"50", : : "gender":"Female" : } ] I am doing this $..name in the JsonPath Extractor which is giving me this in the variable I…
user6348718
  • 1,355
  • 5
  • 21
  • 28
6
votes
2 answers

How do I get value from JSON using JsonPath in Java?

I want to get the value from the JSON object using JsonPath.Could anyone please suggest me the appropriate jars which i would need because as per my knowledge i am getting this exception for the jars i am using for jsonpath . package jsonPg; import…
Tanmay Matondkar
  • 73
  • 1
  • 1
  • 5
6
votes
1 answer

Jayway JsonPath Filter expression for inner array

I have a JSON file in the format below. { "queryResponse":[ { "id":"1", "name":"Parent1", "childList":[ { "id":"11", "type":"A" }, { …
rush
  • 61
  • 2
6
votes
1 answer

Request body matching in WireMock (not JSON/XML)

I am trying to create a API mock with standalone wiremock. The response body depends upon an attribute in the request body. With JSON, I was able to do. Here is sample mapping: { "request":{ "method":"POST", "bodyPatterns":[ …
xploreraj
  • 3,792
  • 12
  • 33
  • 51