JSONPath array filter can't refer to root object ($)
See original GitHub issueThe following JSONPath expression:
$.included[?(@.id == $.data.relationships.target.id)]
would be expected work with the following JSON, but does not: http://api.mocki.io/v1/9c54d246
Individually,
$.included[?(@.id == "foo")]
and
$.data.relationships.target.id
work, but not when combined.
Desktop (please complete the following information):
- OS: Big Sur
- Installation Method: download
- App Version: v2021.1.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
JSONPath: Get root array object using filter of child value
I need to get whole sport object where "inplay == 0" using JsonPath expression. Result should look like that: { "name": "Tennis", "regions":...
Read more >How to Use JSONPath to filter JSON data - Telerik Reporting
In this article we are going to discuss how to use JSONPath expressions in the Data Selector in order to query and filter...
Read more >JSON Path explained - Elements Connect for Jira Server/Data ...
The root element in JSONPath is always referred to as $ regardless if it is an object or array.
Read more >Using JSONPath effectively in AWS Step Functions
This post uses a sample application to highlight effective use of JSONPath and data filtering strategies that can be used in Step Functions....
Read more >12: 9.15. JSON Functions and Operators - PostgreSQL
The field/element/path extraction operators that accept integer JSON array subscripts all support negative subscripting from the end of arrays. The standard ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It will be a breaking change. The
jq
syntax is more complex, but more powerful at the same time. The OP’s case would look like this if used in CLI:@pvarga-dni It seems the issue is with the npm module that is being used in the project. Insomnia uses jsonpath to handle these queries which are not able to process these requests. I have raised an issue with them and we can see if they can support this, details of the issue can be found here. If they get us a fix then all we need to do is update the npm module and it will be working. If you refer to this link, you will see your query works here fine. Another solution to this problem can be we look into the implementation of this type of query in projects p1 and p2 which are
java
andscala
based projects. Once we understand we make the contribution tojsonpath
module and get this working. @develohpanda @dimitropoulos Can you please verify the above details.