Questions tagged [json-path-expression]

A JSON path expression is an expression, possibly in a domain-specific language, specifying a path to to one or more values within a JSON text. The expression may include filters.

Javascript provides a well-known notation for JSON path expressions. JSONPath and JMSEPath are well-known DSLs for JSON path expressions. In jq, any JSON array consisting solely of strings and/or integers can be used as a path expression.

179 questions
55
votes
11 answers

XPath like query for nested python dictionaries

Is there a way to define a XPath type query for nested python dictionaries. Something like this: foo = { 'spam':'eggs', 'morefoo': { 'bar':'soap', 'morebar': {'bacon' : 'foobar'} } } print(…
RickyA
  • 15,465
  • 5
  • 71
  • 95
10
votes
2 answers

How can I use a relative Path or a Wildcard in JQ

Is it possible to use a relative path or name in JQ like the XPath // ? Or is it possible to use an wildcard in JQ like .level1.*.level3.element ?
Mirko Ebert
  • 1,349
  • 1
  • 18
  • 36
6
votes
1 answer

Invalid path expression near attempt to access element

When trying to change a single element in an array, I get Invalid path expression near attempt to access element - but only when the array is captured from --rawInput. Example: # input: [ 1, 0 ] . as $list | $list[0] = 30 # output: [ 30, 0 ] But…
Remy Sharp
  • 4,520
  • 3
  • 23
  • 40
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
4
votes
0 answers

Create Java JSONObject by JSONPath expression

Using this library I am trying to create a JSON Object by jsonpath expression. How can I do it? Sample problem. JsonPath expression: $.data[*].firstname, value = "John doe" The JsonObject should be { "data": [ { "firstname": "John Doe" } …
SvK
  • 41
  • 4
3
votes
0 answers

NewtonSoft JsonPath with C# Syntax

I have a set of objects which I'm deserializing using NewtonSoft.Json 13.0.1. My project is using .Net 5.0 and the language is C#. I want to use JsonPath (Json Path) syntax to determine whether an object matches a given criterion, in particular,…
anonmous
  • 139
  • 1
  • 6
3
votes
1 answer

decode base64 in kubectl jsonpath

I have a command similar to this kubectl get secrets \ --selector='my-selector' \ -o jsonpath='{range .items[*] }{"\n"}{.metadata.labels.cluster-name}{"."}{.metadata.namespace {":"}{"5432"}{"postgres" }{":"}{.data.password}{end}' which outputs a…
Alan
  • 491
  • 4
  • 13
3
votes
0 answers

How to get list of absolute paths from a given filtered JsonPath expression

I am using following library: com.jayway.JsonPath version 2.4.0 I am processing a json string using the shared JsonPath (filtered) expression, and I need to update different values to the different matching json-nodes at the same time, for that I…
TheCodeCache
  • 820
  • 1
  • 7
  • 27
3
votes
2 answers

JsonPath ignore the Debug logs on output

I'm using JsonPath for my JSON parsing work in Java. Is there any ways to remove the debug logs upon running the code? So basically, I am simply trying to run my parsing code in Maven: String pageName = JsonPath.read(json,…
Tina J
  • 4,983
  • 13
  • 59
  • 125
3
votes
2 answers

Apache NiFi evaluatejsonpath processor: JSONPath expression to concatenate 2 attributes

I am using EvaluateJsonPath processor in NiFi to specify a composite primary key for writing my JSON data into elasticsearch. I have to create an attribute called 'key' by concatenating two attributes, lets say 'attr1' and 'attr2'. In…
Skn
  • 140
  • 2
  • 2
  • 13
2
votes
1 answer

JSONPath to get multiple values from nested json

I have a nested JSON in a field that contains multiple important keys that I would like to retrieve as an array: { "tasks": [ { "id": "task_1", "name": "task_1_name", "assignees": [ { "id": "assignee_1", …
Aleeb
  • 35
  • 1
  • 5
2
votes
2 answers

JsonPath - Filter Array and get only the first element

Im trying to filter the elements of this JSON array to return only the first element it will find. { "elements": [{ "urn": "urn:li:lyndaCourse:189800", "details": { "classifications": [{ …
Infor.KS
  • 21
  • 1
  • 3
2
votes
1 answer

Jsonpath how to select this json with inner json node

Jsonpath is new for me and I am leaning this. I can only select the name as $.name. I don't know how to select employeename and type from this json? Could someone tell me how? { "name": "{\r\n \"employeename\": \"Test name\"\r\n}\r\n", "…
Masi Boo
  • 635
  • 1
  • 10
  • 24
2
votes
1 answer

How to get JSONPath to return property of parent of matched element

I have a JSONPath expression that is matching the expected node. But I want to return a property of the parent of that node. Here is the source json: { "totalRecords": 2, "totalRecordsSpecified": true, "recordList": [ { "name":…
Shawn de Wet
  • 5,642
  • 6
  • 57
  • 88
2
votes
1 answer

Get root element using jsonpath based on sub elements condition

I am working with the Jayway JsonPath library to obtain the correct 'id' from below JSON where my phoneNumbers type is 'iPhone'. In general, I would like to know how to find something from the root element of a block when a specific condition is…
Dwarrior
  • 687
  • 2
  • 10
  • 26
1
2 3
11 12