JSONPath :contains filter
nevermind, guys, found a way to do it by just using ECMA inside of JSONPath, though this is not a native selector / operator. Simply used:
$.[?(/find/.test(@.hey))]
the RegExp test( ) method (which JSONPath eval
s behind the scenes).
If anyone has a better answer, though, let me know.
JsonPath expression filtering based on "contains"?
Raw JSON Path doesn't do this, but depending on the implementation you're using, it might be supported.
We're currently in progress writing a formal specification. One of the open issues is the breadth of expression support we want. Feel free to add a comment. Once the spec is defined and published, I imagine most implementations will update to adhere.
jsonPath - how to filter results by matching substring
With regards to full value you can use a Filter Operator like:
$..[?(@.property2 =~ /misery.*?/i)].property2
Demo:
You can extract the 4-digit value out of the variable using Regular Expression Extractor
If you want to do this in one shot:
- Add JSR223 PostProcessor as a child of the request which returns above JSON
Put the following code into "Script" area
vars.put('misery', ((com.jayway.jsonpath.JsonPath.read(prev.getResponseDataAsString(), '$..[?(@.property2 =~ /misery.*?/i)].property2').get(0) =~ ('(\\d+)'))[0][1]))
- Refer the extracted value as
${misery}
where required
More information: Apache Groovy - Why and How You Should Use It
JSONPath - filter by field that name contain '@'
the easy way is replace the '@' character by it's hexadecimal code (\x40) directly into your jsonpath query:
$.media.track[?(@['\x40type']=="Audio")]
JSONPath filter property by value in object
It looks like JSONPath expressions applies only to arrays. See here and here. Your query $.queue[?(@.size>0)]
works for:
{
"queue": [{
"size": 13
},
{
"size": 10
}]
}
Related Topics
Create a Newline for Every X Number of Characters
How to Detect Overflow of React Component Without Reactdom
React Open Modal Window on Click in Another Component
Disabling a Button Within a Stateless Component - React
How to Add Spaces to for Loop Output in JavaScript
Javascript Add Class Active When Click a Link After Load Another Page
Barcode Scanner for Mobile Phone for Website in Form
Invalid Attempt to Spread Non-Iterable Instance
How to Implement Ping/Pong Request for Websocket Connection Alive in JavaScript
Multiply and Sum Input Values Created Dynamically in Jquery
How to Increment a Number After Every 1 Second Using JavaScript
Generate a Weighted Random Number
Get the Value of Datepicker on Change in Jquery
If Check Box Checked Disable Other, If Unchecked Enable All in React
To Check If a String Is Alphanumeric in JavaScript
Get Count of True Values in Json With JavaScript