-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
regex filter on an array returns all the matching string and all the nested array with a match.
Is that by design?
Reproducer
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS com.jayway.jsonpath:json-path:2.9.0
import com.jayway.jsonpath.JsonPath;
import java.util.List;
public class RegexArrayFilterExample {
public static void main(String[] args) {
String json = """
{
"data": [
"apple",
"banana",
["nested-apple", "nested-banana"],
"application"
]
}
""";
System.out.println("JSON: " + json);
// Filter strings matching regex pattern
List<Object> result = JsonPath.read(json, "$.data[?(@ =~ /.*app.*/)]");
System.out.println("Result: " + result);
}
}
Metadata
Metadata
Assignees
Labels
No labels