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
3 answers

How do you reference the root key using JSON Path?

I have data like so: {"key": {"name":"hi", "size":10}} "key" is a dynamic value. It isn't fixed. I can access name and size using this JSON Path: *.name *.size How can I get the value of "key" itself with JSON Path? * gives me the entire row of…
gdm
  • 905
  • 1
  • 15
  • 21
7
votes
2 answers

JSONPath union of multiple different paths

I am trying to build a single JSONPath query which will test existence of two or more paths. Let's consider the following sample document: { "firstName": "John", "lastName" : "doe", "age" : 26, "address" …
KarelHusa
  • 1,995
  • 18
  • 26
7
votes
3 answers

How to add new node to Json using JsonPath?

I'm working with JSON and facing some problems. I want to insert/update a path in a JSON object. In the case that the path doesn't exist, it will be created then I insert a new value. In case that it exits, it will be updated by a new value For…
Uni
  • 187
  • 2
  • 7
  • 18
7
votes
0 answers

JsonPath - how to read attributes from different level

I try to use JsonPath to extract values from attributes at different levels of my json object. Here's my object: { "A": [ { "B": "0", "C": "1", "D": { "E" : "2", "F" :…
Ed Be
  • 79
  • 1
7
votes
1 answer

JsonPath syntax for "does not include", or negative matching?

Consider this sample JSON: { "thing": [ { "name": "foo", "flag": "yep" }, { "name": "bar" }, { "name": "baz", "flag": "nope" } ] } If I wanted to find all the 'name' elements that DID have a…
sprad
  • 313
  • 3
  • 10
7
votes
3 answers

Map a Jsonpath output to a list of POJOs

I'm trying to map directly the output of a Jsonpath to a list of POJO. I'm using Jackson as a mapping provider. Jsonpath output: { "actions" : [ { "parameterDefinitions" : [ { "defaultParameterValue" : { …
tduchateau
  • 4,351
  • 2
  • 29
  • 40
7
votes
2 answers

xpath like query for protobuf messages

I am looking for a xpath like query language for protobuf messages. For example, for the Person message shown below [ borrowed from the Developer guide ] message Person { required string name = 1; required int32 id = 2; optional string email =…
Irfan
  • 71
  • 1
  • 4
7
votes
4 answers

Exclude fields from JSON using JSONPath

I am getting a JSON response from REST service call and want to select only some of the fields from response. I am using JSONPath to filter out the fields. Below is the JSON example: { "store": { "book": [{ "category":…
Darshan Mehta
  • 30,102
  • 11
  • 68
  • 102
7
votes
1 answer

Handling jsonp in rails 3 controller

I want my controller action to handle jsonp requests from jquery $.getJSON. In my controller action i have the following respond_to block: respond_to do |format| format.html { render json: {:items_by_tag => @tagged_item_list}} if…
jimcgh
  • 5,637
  • 4
  • 27
  • 37
7
votes
1 answer

ATLANTBH jmeter-components: JSON Path Assertion

I'm trying to perform a JSON assertion using ATLANTBH jmeter JSON PATH Assertion. However I cant seem to write a correct expression to get the following fields from the JSON feed posted below: 123456789 1009 SOME RANDOM MESSAGE {"api":…
MetaCoder
  • 368
  • 5
  • 22
6
votes
0 answers

How to do 2 filters if k8s' jsonpath is missing AND condition

I need to find all sts whose replicas are still booting. For this I need to filter sts items based on 2 conditions: each item must have a .status.readyReplicas attribute each readyReplicas attribute must be different than the value in…
Alex
  • 1,313
  • 14
  • 28
6
votes
1 answer

How to extract properties from my state machine output when using EventBridge Input Transformers

I'm having trouble passing one of the values returned by my AWS state machine as input to a Lambda using the EventBridge service. I created a state machine in AWS Step Functions to model a specific problem in our domain. Once the state machine…
julealgon
  • 7,072
  • 3
  • 32
  • 77
6
votes
1 answer

How to send specific fields from EventBridge input to its target

I am receiving a webhook event on my AWS EventBridge. The event json body is pretty large and I need to transfer only 4 fields to the target. The fields are…
Lina
  • 1,217
  • 1
  • 15
  • 28
6
votes
1 answer

Webpack bundle with 'jsonpath' dependency

We use a webpack to bundle our lambdas before we deploy them. Ever since we added code that has a dependency on "jsonpath," the code fails immediately with the following. TypeError: Cannot read property '1' of undefined at isFileType…
KickinMhl
  • 1,218
  • 3
  • 14
  • 32
6
votes
3 answers

How to patch container env variable in deployment with kubectl?

When I want to exctract the current value of some container env variabe I could use jsonpath with syntax like: kubectl get pods -l component='somelabel' -n somenamespace -o…
lexadler
  • 245
  • 5
  • 13