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

JMESPath nested AND query (one-liner)

I'm working on an custom Azure Devops and trying to fill my fields through a json file. I manage to get the data one layer deep, but 2 layers seems to be challenging. My source: { "Projects": [ { "Name": "Phoenix", "CatalogItems":…
0
votes
2 answers

pyspark: how to get_json_object for names with spaces (or other weird characters in the name)?

Normally, F.get_json_object(name, "$.element_name") works fine to extract the element_name from a JSON object like this {"element_name" : 1} But what if the name has a space in this? How do I quote the name? {"element name" : 1} this doesn't work…
xiaodai
  • 14,889
  • 18
  • 76
  • 140
0
votes
1 answer

MissingFormatArgument Exception in unit test

I am going to unit test a JSON file. One of the keys is "%changed". However, using JSONPath to test it, gives me an error. How can I successfully test it? .andExpect(jsonPath("$.%Changed").isString()) { "Open": "3,659.87", …
Lucy
  • 43
  • 7
0
votes
0 answers

WebTestClient's DSL cannot retrieve collection when using JSON path

I have a Spring Boot 2.3.2.RELEASE WebFlux application. I'm building a test for a controller using @WebFluxTest and injecting a WebTestClient instance. Everything works fine, but (this one is silly) I can't seem to find a way to retrieve, for a…
x80486
  • 6,627
  • 5
  • 52
  • 111
0
votes
1 answer

$.concat function doesn't work with filter in jayway implementation of jsonPath

I'm trying to apply the jsonPath expression: "$.concat($.[?(@.channel=='one' && @.stream=='test')].air.track.author," - ",$.[?(@.channel=='one' && @.stream=='test')].air.track.title)" To JSON: [ { "channel": "one", "stream": "test", …
antoniOS
  • 370
  • 2
  • 9
0
votes
2 answers

time operator in jsonpath kubectl

I set label "mytime" in timestemp format for my pod. Now i want select all pods with expired time? some think like this: kubectl get pods -o jsonpath='{range .items[*]}{.metadata.labels.mytime<$now()}{.metadata.name}{ "\n"}{end}' but i see…
Tim
  • 155
  • 1
  • 3
  • 13
0
votes
1 answer

Extract values from web service JSON response with JSONPath

I have a JSON response from web service that looks something like this : [ { "id":4, "sourceID":null, "subject":"SomeSubjectOne", "category":"SomeCategoryTwo", "impact":null, "status":"completed" }, { …
arnisli
  • 41
  • 3
0
votes
1 answer

Insomnia: Invalid JSON: Unexpected token ) in JSON at position 0

This is response of the Login request that i need to extract data from. As you can see first line is not JSON format and Insomnia is complaining about it as "Invalid JSON: Unexpected token ) in JSON at position 0" Is there any way to ignore/remove…
0
votes
2 answers

Angular -using jsonPath

In my app I want to use json path. I found this library, but I cannot get it to work from my app. Per the documentation I installed the library and put this line in my component: import {JSONPath} from 'jsonpath-plus'; But I received an error when…
danda
  • 553
  • 10
  • 30
0
votes
1 answer

Jsonpath: Is there a way to any one of the available child nodes using JsonPath

In JsonPath, i am trying to pick attributes from one of the available json nodes. However, i couldn't come up with an expression. I tried using anyOf, but wasn't successful. For instance, i need to pull books from any one of the stores (A or B). I…
0
votes
2 answers

JSON path condifitional index of element based on value of another field

I want to select array element based on value of another object(not array part) { "array": [ { "id": 1 }, { "id": 2 } ], "conditionalField": "ab" } I want select array element based on value of $.conditionalField.…
Oleh Kurpiak
  • 1,339
  • 14
  • 34
0
votes
0 answers

Getting a value from a JSON object using JSONPath

I have the following JSON and I need to get the plain name value using JSONPath: { "data": [ { "code": "ABC", "metadata": { "id": "111", "data": "2020" …
0
votes
2 answers

Extract information of kubernetes annotations with jsonpath

I have this JSON code: { "apiVersion": "autoscaling/v1", "kind": "HorizontalPodAutoscaler", "metadata": { "annotations": { "autoscaling.alpha.kubernetes.io/metrics":…
0
votes
1 answer

Is there a way to extract the keys from JSON using jsonpath-ng?

I want to create a list of keys from JSON (actually JSON Schema). JSON is complex and nested so I am using the jsonpath-ng library. I can't manage to get the list of keys. On the other hand, extracting the values is successful with this syntax:…
Lada
  • 63
  • 2
  • 6
0
votes
1 answer

flatten JSON array with JSONpath

I am trying to flatten the "policy_metrics" array in the following JSON { "ticket": { "url": "https://company.zendesk.com/api/v2/tickets/12107.json", "id": 12107, "description": "test", "priority": "high", "status": "open", …
Jerry
  • 31
  • 1
  • 7