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

json-patch wildcard usage in argocd manifest

Is it possible to replace this --- apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: elastic-operator labels: argocd.application.type: "system" spec: ignoreDifferences: - group: admissionregistration.k8s.io kind:…
carrotcakeslayer
  • 809
  • 2
  • 9
  • 33
8
votes
2 answers

How can I retrieve just the kubectl.kubernetes.io/last-applied-configuration using kubectl -o jsonpath?

I am trying to retrieve the kubernetes last-applied-configuration from a service yaml (under metadata annoations) using kubectl -o jsonpath, but the name of the field is "kubectl.kubernetes.io/last-applied-configuration". I believe the parser is…
user4611739
  • 93
  • 1
  • 1
  • 4
8
votes
1 answer

Access JSON::Path numbers only key

What is the correct syntax to acces a json key that does only has numbers with Perl6 Module JSON::Path? I'm getting "JSON path parse error at position 6" erros. I would like to access items->2018->name: use JSON::Path; my Str $json = 「 { "items"…
LuVa
  • 2,288
  • 2
  • 10
  • 20
8
votes
1 answer

JSONPath query on MongoDB?

We have User data stored into MongoDB. The client gives a JSONPath query to ask for filtered set of users. Eg: $.users[@.salary > 10000] is a JSONPath query given to retrieve users with salary greater than 10000. Data: "users": [ { …
Siddharth Trikha
  • 2,648
  • 8
  • 57
  • 101
8
votes
1 answer

Is JPath the same as JSONPath in JSON.NET?

Although the names look similar, small changes could be tricky. Unfortunately I cannot find decent info about JPath. The docs of JSON.NET are talking about JPath and JSONPath and I think there are the same. Am I correct? A String that contains a…
Julian
  • 33,915
  • 22
  • 119
  • 174
8
votes
1 answer

How to compare two jsonPath values in MockMvc

I am writing tests for my spring application using MockMvc. Assume that my json result will have the following format: { "available": true, "location": [ {"ID": 1, "path": "local1"}, {"ID": 2, "path": "local2"}, {"ID": 3, "path":…
Ock
  • 1,262
  • 3
  • 18
  • 38
8
votes
4 answers

JSONPath get the id of a parent element by a sub-child value

Given the following JSON I want to get the id field of the parent by an equals text compare of a sub-child element: { "datapoints": [{ "id": "default.1", "definedBy": "default/0.1", "featureValues": { …
Bruno Bieri
  • 9,724
  • 11
  • 63
  • 92
8
votes
0 answers

Delete element in JSONPath Java

I have a JSON file like this: { "objects": [{ "type": "FirstType", (...) "details": { "id": 1, "name": "FirstElementOfTheFirstType", "font": "18px arial" …
user3529850
  • 1,632
  • 5
  • 32
  • 51
8
votes
1 answer

REST-Assured - JsonPath for fetching a list of values

I'm using REST-Assured for testing some RESTful webservices. Here's my JSON: { "status":true, "responseData":{ "orderLevelReasons":[ { "reasons":[ { …
Akshay Maldhure
  • 787
  • 2
  • 19
  • 38
8
votes
1 answer

Set specific JSONPATH element value

I was trying to set the author value from the following JSON text but my code is removing the all other child's of the json text. { "store": { "book": [ { "category": "reference", "author":…
user741699
  • 93
  • 1
  • 1
  • 5
8
votes
3 answers

Is there anyway to validate if a syntax of jsonpath is correct?

Hi I am trying to find a way to validate jsonpath entered by user before evaluating it. I was hoping use something like a regex to do that but so far I could not find any doc/resource on how to validate jsonpath syntax. All searched return…
Rajind Ruparathna
  • 2,215
  • 24
  • 55
8
votes
3 answers

Newtonsoft update JObject from JSON path?

I am aware of using the select tokens function to pass a json path. For example: JObject jObect = JObject.Parse("{some json string}"); JToken jToken = jObject.SelectToken("root.item[0].myProperty"); What I am looking for is a simple manner to…
PMOrion
  • 169
  • 2
  • 10
8
votes
1 answer

Editing JSON using JSONPath

Hello SO community :)! I want to create method which will let user to edit (or add) JSON specific value or object (located in JSON by JSONPath). Below simple example what is on my mind. User always enters JSON, JSONPath and value/object to change.…
8
votes
2 answers

JSON Get parent object from child object

How can I get discount value if brand_id=='983'. Sample JSON: { "prods": [ { "info": { "rate": 100 }, "grocery": [ { …
Vivek Singh
  • 3,641
  • 2
  • 22
  • 27
8
votes
0 answers

Update array element using JsonPath

I am trying to replace a certain element in an a Json array using jayway's JsonPath in Java. Example: { "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the…
florind
  • 361
  • 4
  • 12