本文整理了Java中com.fasterxml.jackson.databind.JsonNode.findValues()
方法的一些代码示例,展示了JsonNode.findValues()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.findValues()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:findValues
[英]Method for finding JSON Object fields with specified name, and returning found ones as a List. Note that sub-tree search ends if a field is found, so possible children of result nodes are not included. If no matching fields are found in this node or its descendants, returns an empty List.
[中]方法查找具有指定名称的JSON对象字段,并将找到的字段作为列表返回。请注意,如果找到字段,则子树搜索将结束,因此不包括结果节点的可能子节点。如果在此节点或其子节点中未找到匹配字段,则返回空列表。
代码示例来源:origin: redisson/redisson
@Override
public List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)
{
for (JsonNode node : _children) {
foundSoFar = node.findValues(fieldName, foundSoFar);
}
return foundSoFar;
}
代码示例来源:origin: redisson/redisson
/**
* Method for finding JSON Object fields with specified name, and returning
* found ones as a List. Note that sub-tree search ends if a field is found,
* so possible children of result nodes are <b>not</b> included.
* If no matching fields are found in this node or its descendants, returns
* an empty List.
*
* @param fieldName Name of field to look for
*/
public final List<JsonNode> findValues(String fieldName)
{
List<JsonNode> result = findValues(fieldName, null);
if (result == null) {
return Collections.emptyList();
}
return result;
}
代码示例来源:origin: redisson/redisson
@Override
public List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)
{
for (Map.Entry<String, JsonNode> entry : _children.entrySet()) {
if (fieldName.equals(entry.getKey())) {
if (foundSoFar == null) {
foundSoFar = new ArrayList<JsonNode>();
}
foundSoFar.add(entry.getValue());
} else { // only add children if parent not added
foundSoFar = entry.getValue().findValues(fieldName, foundSoFar);
}
}
return foundSoFar;
}
代码示例来源:origin: com.fasterxml.jackson.core/com.springsource.com.fasterxml.jackson.core.jackson-databind
@Override
public List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)
{
if (_children != null) {
for (JsonNode node : _children) {
foundSoFar = node.findValues(fieldName, foundSoFar);
}
}
return foundSoFar;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
@Override
public List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)
{
if (_children != null) {
for (JsonNode node : _children) {
foundSoFar = node.findValues(fieldName, foundSoFar);
}
}
return foundSoFar;
}
代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all
@Override
public List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)
{
for (JsonNode node : _children) {
foundSoFar = node.findValues(fieldName, foundSoFar);
}
return foundSoFar;
}
代码示例来源:origin: com.jwebmp.jackson.core/jackson-databind
@Override
public List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)
{
for (JsonNode node : _children) {
foundSoFar = node.findValues(fieldName, foundSoFar);
}
return foundSoFar;
}
代码示例来源:origin: hstaudacher/osgi-jax-rs-connector
@Override
public List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)
{
for (JsonNode node : _children) {
foundSoFar = node.findValues(fieldName, foundSoFar);
}
return foundSoFar;
}
代码示例来源:origin: Nextdoor/bender
@Override
public List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)
{
for (JsonNode node : _children) {
foundSoFar = node.findValues(fieldName, foundSoFar);
}
return foundSoFar;
}
代码示例来源:origin: bill1012/AdminEAP
List<JsonNode> forms=modelNode.findValues("formkeydefinition");
for (JsonNode form : forms) {
String formName=form.textValue();
代码示例来源:origin: stackoverflow.com
JsonNode node = mapper.readValue("[{\"listed_count\":1720,\"status\":{\"retweet_count\":78}}]]", JsonNode.class);
System.out.println(node.findValues("retweet_count").get(0).asInt());
代码示例来源:origin: stackoverflow.com
ObjectMapper mapper = new ObjectMapper();
JsonNode data = mapper.readTree(json);
data.findValues("_source"); // [{"id":"de","title":"something 1"}, {"id":"def","title":"something 1"}]
//If you want to convert it to custom object
List<Source> sources = mapper.convertValue(data.findValues("_source"), new TypeReference<List<Source>>() {});
代码示例来源:origin: stackoverflow.com
JsonNode node = mapper.readValue("[{\"id\":\"value11\",\"name\": \"value12\",\"qty\":\"value13\"},"
System.out.println("id : "+node.findValues("id").get(0).asText());
代码示例来源:origin: stackoverflow.com
ObjectMapper mapper = new ObjectMapper();
JsonNode root = mapper.readTree(json);
List<JsonNode> values = root.findValues("Value");
// or if you want values as String, use "findValuesAsText" to get List<String>
代码示例来源:origin: HuygensING/timbuctoo
@Override
public String getNextToken() {
String token = null;
List<JsonNode> sortNodes = resultNode.findValues("sort");
if (!sortNodes.isEmpty()) {
token = sortNodes.get(sortNodes.size() - 1).toString();
}
return token;
}
代码示例来源:origin: stackoverflow.com
try {
String json = "{\"response\":[{\"id\":\"1\",\"name\":\"xx\"},{\"id\":\"2\",\"name\":\"yy\"}],\"errorMsg\":\"\",\"code\":0}";
ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readTree(json);
List<Response> responses = mapper.convertValue(node.findValues("response").get(0), new TypeReference<List<Response>>() {});
System.out.println(responses);
} catch (JsonProcessingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
代码示例来源:origin: Nextdoor/bender
@Override
public List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)
{
for (Map.Entry<String, JsonNode> entry : _children.entrySet()) {
if (fieldName.equals(entry.getKey())) {
if (foundSoFar == null) {
foundSoFar = new ArrayList<JsonNode>();
}
foundSoFar.add(entry.getValue());
} else { // only add children if parent not added
foundSoFar = entry.getValue().findValues(fieldName, foundSoFar);
}
}
return foundSoFar;
}
代码示例来源:origin: stackoverflow.com
JsonNode json = request().body().asJson();
Logger.info("JSON : " + json.findPath("in").findPath("id"));
Logger.info("JSON : " + json.findValues("in"));
List<JsonNode> ins = new org.json.simple.JSONArray();
ins = json.findValues("in");
for (final JsonNode objNode : ins) {
for (final JsonNode element : objNode) {
Logger.info(">>>>>" + element.findPath("id"));
//create my object for database
}
}
代码示例来源:origin: org.apereo.cas/cas-server-support-x509-core
@Override
public X509CertificateCredential deserialize(final JsonParser jp,
final DeserializationContext deserializationContext) throws IOException {
val oc = jp.getCodec();
val node = JsonNode.class.cast(oc.readTree(jp));
val certs = new ArrayList<X509Certificate>();
node.findValues("certificates").forEach(n -> {
val cert = n.get(0).textValue();
val data = EncodingUtils.decodeBase64(cert);
certs.add(CertUtils.readCertificate(new InputStreamResource(new ByteArrayInputStream(data))));
});
return new X509CertificateCredential(certs.toArray(X509Certificate[]::new));
}
}
代码示例来源:origin: org.infinispan/infinispan-server-rest
@Test(dataProvider = "HttpMethodProvider")
public void testProjections(HttpMethod method) throws Exception {
JsonNode results = query("Select name, surname from org.infinispan.rest.search.entity.Person", method);
assertEquals(results.get(TOTAL_RESULTS).intValue(), 4);
List<JsonNode> names = results.findValues("name");
List<JsonNode> surnames = results.findValues("surname");
List<JsonNode> streets = results.findValues("street");
List<JsonNode> gender = results.findValues("gender");
assertEquals(4, names.size());
assertEquals(4, surnames.size());
assertEquals(0, streets.size());
assertEquals(0, gender.size());
}
内容来源于网络,如有侵权,请联系作者删除!