Created
June 4, 2021 17:12
-
-
Save robinhowlett/9b405d72162ba75ecc856b87298ea5f2 to your computer and use it in GitHub Desktop.
JBang.dev-compatible test for Jayway Json negative filters for empty strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//DEPS com.jayway.jsonpath:json-path:2.1.0 | |
import com.jayway.jsonpath.JsonPath; | |
import com.jayway.jsonpath.ReadContext; | |
import java.util.List; | |
public class JsonPathTest { | |
public static void main(String[] args) { | |
String json = "{\"phoneNumbers\": [\"a\", 1, false, \"\", null, \"hi\", -1]}"; | |
ReadContext ctx = JsonPath.parse(json); | |
List<Object> result = ctx.read("$.phoneNumbers[?(@ != '')]"); | |
System.out.println(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment