Java Code Examples for com.fasterxml.jackson.databind.JsonNode#findValuesAsText()

The following examples show how to use com.fasterxml.jackson.databind.JsonNode#findValuesAsText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConnectedRESTQA.java    From java-client-api with Apache License 2.0 7 votes vote down vote up
public static String[] getHosts() {
	try {
		DefaultHttpClient client = new DefaultHttpClient();
		client.getCredentialsProvider().setCredentials(new AuthScope(host_name, getAdminPort()),
				new UsernamePasswordCredentials("admin", "admin"));
		HttpGet get = new HttpGet("http://" + host_name + ":" + admin_port + "/manage/v2/hosts?format=json");

		HttpResponse response = client.execute(get);
		ResponseHandler<String> handler = new BasicResponseHandler();
		String body = handler.handleResponse(response);
		JsonNode actualObj = new ObjectMapper().readTree(body);
		JsonNode nameNode = actualObj.path("host-default-list").path("list-items");
		List<String> hosts = nameNode.findValuesAsText("nameref");
		String[] s = new String[hosts.size()];
		hosts.toArray(s);
		return s;

	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
Example 2
Source File: ArrayNode.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public List<String> findValuesAsText(String fieldName, List<String> foundSoFar)
{
    for (JsonNode node : _children) {
        foundSoFar = node.findValuesAsText(fieldName, foundSoFar);
    }
    return foundSoFar;
}
 
Example 3
Source File: HistoricTaskLogCollectionResourceTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void expectSequence(JsonNode list, List<String> ids, List<String> types) {
    assertThat(list).hasSize(ids.size());
    List<String> resultingIds = list.findValuesAsText("taskId");
    assertThat(resultingIds).isEqualTo(ids);
    List<String> resultingTypes = list.findValuesAsText("type");
    assertThat(resultingTypes).isEqualTo(types);
}
 
Example 4
Source File: LinkedInAuthFilter.java    From para with Apache License 2.0 5 votes vote down vote up
private String getProfilePicture(JsonNode profileNode) {
	String url = "";
	JsonNode picNode = profileNode.at("/profilePicture/displayImage~");
	if (!picNode.isMissingNode()) {
		List<String> elements = picNode.findValuesAsText("identifier");
		for (String picUrl : elements) {
			url = picUrl;
			if (picUrl.contains("400_400")) {
				break;
			}
		}
	}
	return url;
}
 
Example 5
Source File: CommonPrefixesDeserializer.java    From bce-sdk-java with Apache License 2.0 4 votes vote down vote up
@Override
public List<String> deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException, JsonProcessingException {
    JsonNode node = jsonParser.getCodec().readTree(jsonParser);
    return node.findValuesAsText("prefix");
}