Created
December 12, 2021 13:33
-
-
Save navi2589/ecbd7a71db16c63eb0b23028e5d4ecb6 to your computer and use it in GitHub Desktop.
This file contains 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
import com.jayway.jsonpath.Configuration; | |
import com.jayway.jsonpath.DocumentContext; | |
import com.jayway.jsonpath.JsonPath; | |
import com.jayway.jsonpath.Option; | |
import com.jayway.jsonpath.ParseContext; | |
public class Solution { | |
private static final Configuration configuration = Configuration.builder().options(Option.SUPPRESS_EXCEPTIONS).build(); | |
private static Configuration getConfiguration() { | |
return configuration; | |
} | |
private static ParseContext getParseContext() { | |
return JsonPath.using(getConfiguration()); | |
} | |
public static void main(String[] args) { | |
DocumentContext documentContext = getParseContext().parse("{\"a\": 1,\"b\":2}"); | |
System.out.println("reading json value of json attribute a " + documentContext.read("$.a")); | |
System.out.println("reusing documentContext to read json value of json attribute b " + documentContext.read("$.b")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment