Package com.jayway.jsonpath

Examples of com.jayway.jsonpath.Configuration


        //String result = JsonPath.read(SIMPLE_MAP, "$.not-found");

        //assertThat(result).isNull();

        Configuration configuration = Configuration.builder().options(Option.SUPPRESS_EXCEPTIONS).build();

        String json = "{\"a\":{\"b\":1,\"c\":2}}";
        assertNull(JsonPath.parse(SIMPLE_MAP, configuration).read("$.not-found"));

View Full Code Here



    @Test(expected = PathNotFoundException.class)
    public void issue_22() throws Exception {

        Configuration configuration = Configuration.defaultConfiguration();

        String json = "{\"a\":{\"b\":1,\"c\":2}}";
        JsonPath.parse(json, configuration).read("a.d");
    }
View Full Code Here

        JsonPath.parse(json, configuration).read("a.d");
    }
    @Test
    public void issue_22c() throws Exception {
        //Configuration configuration = Configuration.builder().build();
        Configuration configuration = Configuration.builder().options(Option.SUPPRESS_EXCEPTIONS).build();

        String json = "{\"a\":{\"b\":1,\"c\":2}}";
        assertNull(JsonPath.parse(json, configuration).read("a.d"));
    }
View Full Code Here



        String json = "{\"a\": {}}";

        Configuration configuration = Configuration.defaultConfiguration().setOptions(Option.SUPPRESS_EXCEPTIONS);
        Assertions.assertThat(JsonPath.using(configuration).parse(json).read("a.x")).isNull();

        try {
            read(json, "a.x");
View Full Code Here

    }


    @Test
    public void last_token_defaults_to_null() {
        Configuration configuration = Configuration.builder().options(Option.DEFAULT_PATH_LEAF_TO_NULL).build();

        assertNull(JsonPath.parse(DOCUMENT, configuration).read("$.children[2].age"));
    }
View Full Code Here

        String error = null;
        long time;
        Object res = null;


        Configuration configuration = Configuration.defaultConfiguration();
        if(flagWrap){
            configuration = configuration.addOptions(Option.ALWAYS_RETURN_LIST);
        }
        if(flagSuppress){
            configuration = configuration.addOptions(Option.SUPPRESS_EXCEPTIONS);
        }
        if (!optionAsValues) {
            configuration = configuration.addOptions(Option.AS_PATH_LIST);
        }
        if(flagNullLeaf){
            configuration = configuration.addOptions(Option.DEFAULT_PATH_LEAF_TO_NULL);
        }
        if(flagRequireProps){
            configuration = configuration.addOptions(Option.REQUIRE_PROPERTIES);
        }

        long now = System.currentTimeMillis();
        try {
            res = JsonPath.using(configuration).parse(json).read(path);
View Full Code Here

     * {@inheritDoc}
     */
    public JsonAsserter assertNotDefined(String path) {

        try {
            Configuration c = Configuration.defaultConfiguration();

            JsonPath.using(c).parse(jsonObject).read(path);
            throw new AssertionError(format("Document contains the path <%s> but was expected not to.", path));
        } catch (PathNotFoundException e) {
        }
View Full Code Here

    }

    @Override
    public JsonAsserter assertNotDefined(String path, String message) {
        try {
            Configuration c = Configuration.defaultConfiguration();

            JsonPath.using(c).parse(jsonObject).read(path);

            throw new AssertionError(format("Document contains the path <%s> but was expected not to.", path));
        } catch (PathNotFoundException e) {
View Full Code Here

        return String.valueOf(readObjectValue(jsonPathExpression));
    }

    public void writeValue(String jsonPathExpression, Object value) {
        PlainJavaJsonProvider provider = new PlainJavaJsonProvider();
        Configuration configuration = Configuration.builder().jsonProvider(provider).build();
        jsonObject = provider.parse(currentJson);
        JsonPath path = JsonPath.compile(jsonPathExpression);
        LinkedList<PathToken> pathTokens = getPathTokensFrom(path);
        PathToken endToken = pathTokens.removeLast();
        int index = pathTokens.size();
View Full Code Here

        return currentJson;
    }

    public <T> T readObjectValue(String jsonPathExpression) {
        PlainJavaJsonProvider provider = new PlainJavaJsonProvider();
        Configuration configuration = Configuration.builder().jsonProvider(provider).build();
        JsonPath jsonPath = JsonPath.compile(jsonPathExpression);
        return jsonPath.read(jsonObject, configuration);
    }
View Full Code Here

TOP

Related Classes of com.jayway.jsonpath.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.