Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.JsonNode.path()


        JsonNode currentNode = tree;
        for (String pathElement : Splitter.on('/').omitEmptyStrings().split(mapping)) {
            if (!currentNode.has(pathElement)) {
                return MissingNode.getInstance();
            }
            currentNode = currentNode.path(pathElement);
        }
        return currentNode;
    }
}
View Full Code Here


        JsonNode propertiesSchema = root.get("properties");
        assertNotNull(propertiesSchema);
        JsonNode property1Schema = propertiesSchema.get("property1");
        assertNotNull(property1Schema);
        assertEquals("integer", property1Schema.get("type").asText());
        assertEquals(false, property1Schema.path("required").booleanValue());
        JsonNode property2Schema = propertiesSchema.get("property2");
        assertNotNull(property2Schema);
        assertEquals("string", property2Schema.get("type").asText());
        assertEquals(false, property2Schema.path("required").booleanValue());
        JsonNode property3Schema = propertiesSchema.get("property3");
View Full Code Here

        assertEquals("integer", property1Schema.get("type").asText());
        assertEquals(false, property1Schema.path("required").booleanValue());
        JsonNode property2Schema = propertiesSchema.get("property2");
        assertNotNull(property2Schema);
        assertEquals("string", property2Schema.get("type").asText());
        assertEquals(false, property2Schema.path("required").booleanValue());
        JsonNode property3Schema = propertiesSchema.get("property3");
        assertNotNull(property3Schema);
        assertEquals("array", property3Schema.get("type").asText());
        assertEquals(false, property3Schema.path("required").booleanValue());
        assertEquals("string", property3Schema.get("items").get("type").asText());
View Full Code Here

        assertEquals("string", property2Schema.get("type").asText());
        assertEquals(false, property2Schema.path("required").booleanValue());
        JsonNode property3Schema = propertiesSchema.get("property3");
        assertNotNull(property3Schema);
        assertEquals("array", property3Schema.get("type").asText());
        assertEquals(false, property3Schema.path("required").booleanValue());
        assertEquals("string", property3Schema.get("items").get("type").asText());
        JsonNode property4Schema = propertiesSchema.get("property4");
        assertNotNull(property4Schema);
        assertEquals("array", property4Schema.get("type").asText());
        assertEquals(false, property4Schema.path("required").booleanValue());
View Full Code Here

        assertEquals(false, property3Schema.path("required").booleanValue());
        assertEquals("string", property3Schema.get("items").get("type").asText());
        JsonNode property4Schema = propertiesSchema.get("property4");
        assertNotNull(property4Schema);
        assertEquals("array", property4Schema.get("type").asText());
        assertEquals(false, property4Schema.path("required").booleanValue());
        assertEquals("number", property4Schema.get("items").get("type").asText());
    }
   
    @JsonFilter("filteredBean")
    protected static class FilteredBean {
View Full Code Here

        String generated = mapper.writeValueAsString( jNode)//back slashes are gone
        JsonNode out = mapper.readValue( generated, JsonNode.class );   //crashes here
        assertTrue(out.isObject());
        assertEquals(1, out.size());
        String value = out.path("field").asText();
        assertNotNull(value);
    }

    // Issue#186
    public void testNullHandling() throws Exception
View Full Code Here

        assertEquals(3, node.intValue());
        node = root.findParent("b");
        assertNotNull(node);
        assertTrue(node.isObject());
        assertEquals(1, ((ObjectNode) node).size());
        assertEquals(3, node.path("b").intValue());
    }

    public void testMatchingMultiple() throws Exception
    {
        JsonNode root = _buildTree();
View Full Code Here

    assertField(root, "environment", ENVIRONMENT);
    assertField(root, "serverName", SERVER_NAME);
    assertField(root, "message", LOG_MESSAGE);
    assertField(root, "logMessage", LOG_MESSAGE);
    assertField(root, "type", "N/A");
    String backtrace = root.path("backtrace").asText();
    Assert.assertTrue(backtrace.contains("testNonExceptionAppender"));
    Assert.assertFalse(backtrace.contains("writeFormattedException"));
  }

View Full Code Here

    {
        // Need to override this method, which otherwise would work just fine,
        // since we have legacy JSON Object format to support too:
        if (jp.getCurrentToken() == JsonToken.START_OBJECT) { // old style
            JsonNode root = jp.readValueAsTree();
            String host = root.path("hostText").asText();
            JsonNode n = root.get("port");
            if (n == null) {
                return HostAndPort.fromString(host);
            }
            return HostAndPort.fromParts(host, n.asInt());
View Full Code Here

    final OAuthCalculator op = getOAuthCalculator(info);

    final JsonNode userJson = signedOauthGet(userInfoUrl, op);

    return new XingAuthUser(userJson.path(NODE_USERS).get(0), info);
  }

    @Override
    protected void checkError(Http.Request request) throws AuthException {
        final String error = request.getQueryString(XING_ERROR);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.