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

OR operator in JSONPath?

Using a single JSONPath expression alone, is it possible to do some kind of 'OR' or '||' operator. For example, these two JSONPath boolean expressions work to check the severity of a log JSON file: $..log[?(@.severity ==…
Andrew G
  • 412
  • 1
  • 5
  • 14
18
votes
3 answers

How to get the first element when filter in jsonpath?

So I'm working on the below json: { "id": "", "owner": "some dude", "metaData": { "request": { "ref": null, "contacts":[ { "email": null, "name": null, …
Vu Viet Dung
  • 343
  • 1
  • 3
  • 6
18
votes
1 answer

Optional JsonPath using Jayway

Question: I have a service that takes in a JSON string as input. The JSON schema is different every time where some fields are not always present. How can I query the values of those fields using Jayway's JsonPath when they are present? What I've…
SegFault
  • 2,526
  • 4
  • 21
  • 41
17
votes
5 answers

JSONPath :contains filter

Hey all, I was wondering if any knew of a way to use a regular expression or wildcard operator (or pehaps '%LIKE%' in SQL) so I could use JSONPath to do searching within a large set of JSON data. For instance (and yes, I'm parsing, not eval( )ing my…
Dan Beam
  • 3,632
  • 2
  • 23
  • 27
16
votes
4 answers

AWS Step Function - Adding dynamic value to Pass state type

I have the following state defined in my state machine. "loop":{ "Type": "Pass", "Result":{ "totalCount": "$.newFieldsResponse.body.count", "currentCount": 0, "step": 1 }, "ResultPath":…
Furqan Shaikh
  • 371
  • 2
  • 4
  • 13
16
votes
3 answers

JsonPath AND Operator on Array

I have an array in JSON and I would like to apply two filters to it like so: $._embedded.values[0]._embedded.data[?(@.var1='value1' && @.var2='value2')] I need to select only those elements from the array that satisfies the AND operation. However,…
mchinaloy
  • 1,444
  • 3
  • 25
  • 42
16
votes
3 answers

JsonPath NoClassDefFoundError, or an alternative to JsonPath in Java

For reasons related to the project I'm working on, I'd like an entire query to a JSON file to be held as a string, for example, $.store.book[*].title (rather than having to store each level of the document temporarily as a separate object). I'm…
firechant
  • 886
  • 1
  • 14
  • 22
15
votes
8 answers

JSONPath or other XPath like utility for JSON/Javascript; or Jquery JSON

I have been looking at JSONPath and though it seems pretty well done, I wonder if anyone has worked with it and can comment on its usability, or can recommend alternatives? What would be really slick is if there was a plugin for JQuery that did…
jwl
  • 10,268
  • 14
  • 53
  • 91
15
votes
1 answer

JsonPath not working properly in Spring Cloud Data Flow filter component

I'm trying to write a simple SCDF flow that reads from Kafka, filters the messages by presence of specific value and pushes data into Mongo. As part of this i had to wrote following #jsonPath …
Ján Srniček
  • 505
  • 1
  • 10
  • 34
15
votes
2 answers

Find a JSON property name that starts with something using JSON Path

Is it possible to find a property name that matches a regex pattern (or at least starts with) using JSON Path. In XPath I can use name() but I haven't been able to find the JSON Path equivalent. Basically, I what to find all property names that…
Richard Schneider
  • 34,944
  • 9
  • 57
  • 73
15
votes
3 answers

JsonPath expression to filter using regex

We are using a tool which uses jayway library for evaluating JSONpath expression. Javascript does NOT seem to work with it. How can I use regular expression in the JSONPath in such a case. For instance, in the below example I would like to filter…
sjn
  • 171
  • 1
  • 1
  • 7
15
votes
4 answers

JsonPath: Selecting root level field if satisfies a condition

Given the below Json input: { "category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99 } I need to select the author field if the author matches a given name for eg. Evelyn Waugh. I am struggling to write…
Drona
  • 6,886
  • 1
  • 29
  • 35
14
votes
1 answer

JsonPath get length of array after filter

Hi I want get legth of array after Filter with JsonPath. Is it possible ? My filter is $.issues.[?(@.severity == 'MAJOR')].length() My Json is { "issues": [ { "severity": "MAJOR" }, { …
Matthis.h
  • 849
  • 3
  • 14
  • 30
14
votes
2 answers

Sublime text 3 plugin to get JSON path

I am after a plugin or technique in sublime text 3 to get what I will call the fully qualified path of the json element that is selected in the editor window. Somethink like: http://jsonpath.com/ I want to get a result somewhere that I can copy, I…
MattG
  • 5,589
  • 5
  • 36
  • 52
14
votes
1 answer

How do you escape the @ symbol in jsonpath?

Given a json list like this: { "listRel:customFieldList": { "platformCore:customField": [ { "@internalId": "801", "scriptId": "custentity_admin_contact_cweb", …
redwards510
  • 1,802
  • 1
  • 17
  • 23