JSONPath :contains filter

Also, may be it will be useful for someone. Link to JSONPath Notation

It works for me (JMeter 4.0)

=~

Match a JavaScript regular expression. For example, [?(@.description =~ /cat.*/i)] matches items whose description starts with cat (case-insensitive).


If anyone wants the contains solution in Java then this works with JsonPath

Filter<?> filter = Filter.filter(Criteria.where("hey").regex(Pattern.compile(".*find.*")));
System.out.println(JsonPath.read(json, "$..[?]", filter));

Imports

import com.jayway.jsonpath.Criteria;
import com.jayway.jsonpath.Filter;
import com.jayway.jsonpath.JsonPath;

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 evals behind the scenes).

If anyone has a better answer, though, let me know.


=~ worked for me. Tested with Jmeter 5.3 JSON Extractor.