本文整理了Java中com.fasterxml.jackson.databind.JsonNode.findValuesAsText()
方法的一些代码示例,展示了JsonNode.findValuesAsText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.findValuesAsText()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:findValuesAsText
[英]Similar to #findValues, but will additionally convert values into Strings, calling #asText.
[中]类似于#findValues,但将另外将值转换为字符串,调用#asText。
代码示例来源:origin: redisson/redisson
@Override
public List<String> findValuesAsText(String fieldName, List<String> foundSoFar)
{
for (JsonNode node : _children) {
foundSoFar = node.findValuesAsText(fieldName, foundSoFar);
}
return foundSoFar;
}
代码示例来源:origin: redisson/redisson
/**
* Similar to {@link #findValues}, but will additionally convert
* values into Strings, calling {@link #asText}.
*/
public final List<String> findValuesAsText(String fieldName)
{
List<String> result = findValuesAsText(fieldName, null);
if (result == null) {
return Collections.emptyList();
}
return result;
}
代码示例来源:origin: redisson/redisson
@Override
public List<String> findValuesAsText(String fieldName, List<String> foundSoFar)
{
for (Map.Entry<String, JsonNode> entry : _children.entrySet()) {
if (fieldName.equals(entry.getKey())) {
if (foundSoFar == null) {
foundSoFar = new ArrayList<String>();
}
foundSoFar.add(entry.getValue().asText());
} else { // only add children if parent not added
foundSoFar = entry.getValue().findValuesAsText(fieldName,
foundSoFar);
}
}
return foundSoFar;
}
代码示例来源:origin: apache/tika
@Override
public String translate(String text, String sourceLanguage,
String targetLanguage) throws TikaException, IOException {
if (!this.isAvailable)
return text;
Response response = client.accept(MediaType.APPLICATION_JSON)
.query("key", apiKey).query("source", sourceLanguage)
.query("target", targetLanguage).query("q", text).get();
BufferedReader reader = new BufferedReader(new InputStreamReader(
(InputStream) response.getEntity(), UTF_8));
String line = null;
StringBuffer responseText = new StringBuffer();
while ((line = reader.readLine()) != null) {
responseText.append(line);
}
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonResp = mapper.readTree(responseText.toString());
return jsonResp.findValuesAsText("translatedText").get(0);
}
代码示例来源:origin: apache/tika
@Override
public String translate(String text, String sourceLanguage,
String targetLanguage) throws TikaException, IOException {
if (!this.isAvailable)
return text;
Response response = client.accept(MediaType.APPLICATION_JSON)
.query("user_key", userKey).query("source", sourceLanguage)
.query("target", targetLanguage).query("q", text).get();
BufferedReader reader = new BufferedReader(new InputStreamReader(
(InputStream) response.getEntity(), UTF_8));
String line = null;
StringBuffer responseText = new StringBuffer();
while ((line = reader.readLine()) != null) {
responseText.append(line);
}
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonResp = mapper.readTree(responseText.toString());
if (jsonResp.findValuesAsText("errors").isEmpty()) {
return jsonResp.findValuesAsText("translation").get(0);
} else {
throw new TikaException(jsonResp.findValue("errors").get(0).asText());
}
}
代码示例来源:origin: apache/tika
JsonNode jsonResp = mapper.readTree(responseText.toString());
if (!jsonResp.findValuesAsText("code").isEmpty()) {
String code = jsonResp.findValuesAsText("code").get(0);
if (code.equals("200")) {
return jsonResp.findValue("text").get(0).asText();
代码示例来源:origin: apache/tika
JsonNode jsonResp = responseMapper.readTree(responseText.toString());
if (jsonResp.findValuesAsText("outputText") != null) {
return jsonResp.findValuesAsText("outputText").get(0);
} else {
throw new TikaException(jsonResp.findValue("message").get(0).asText());
代码示例来源:origin: com.jwebmp.jackson.core/jackson-databind
@Override
public List<String> findValuesAsText(String fieldName, List<String> foundSoFar)
{
for (JsonNode node : _children) {
foundSoFar = node.findValuesAsText(fieldName, foundSoFar);
}
return foundSoFar;
}
代码示例来源:origin: Nextdoor/bender
@Override
public List<String> findValuesAsText(String fieldName, List<String> foundSoFar)
{
for (JsonNode node : _children) {
foundSoFar = node.findValuesAsText(fieldName, foundSoFar);
}
return foundSoFar;
}
代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all
@Override
public List<String> findValuesAsText(String fieldName, List<String> foundSoFar)
{
for (JsonNode node : _children) {
foundSoFar = node.findValuesAsText(fieldName, foundSoFar);
}
return foundSoFar;
}
代码示例来源:origin: com.fasterxml.jackson.core/com.springsource.com.fasterxml.jackson.core.jackson-databind
@Override
public List<String> findValuesAsText(String fieldName, List<String> foundSoFar)
{
if (_children != null) {
for (JsonNode node : _children) {
foundSoFar = node.findValuesAsText(fieldName, foundSoFar);
}
}
return foundSoFar;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
@Override
public List<String> findValuesAsText(String fieldName, List<String> foundSoFar)
{
if (_children != null) {
for (JsonNode node : _children) {
foundSoFar = node.findValuesAsText(fieldName, foundSoFar);
}
}
return foundSoFar;
}
代码示例来源:origin: hstaudacher/osgi-jax-rs-connector
@Override
public List<String> findValuesAsText(String fieldName, List<String> foundSoFar)
{
for (JsonNode node : _children) {
foundSoFar = node.findValuesAsText(fieldName, foundSoFar);
}
return foundSoFar;
}
代码示例来源:origin: hstaudacher/osgi-jax-rs-connector
/**
* Similar to {@link #findValues}, but will additionally convert
* values into Strings, calling {@link #asText}.
*/
public final List<String> findValuesAsText(String fieldName)
{
List<String> result = findValuesAsText(fieldName, null);
if (result == null) {
return Collections.emptyList();
}
return result;
}
代码示例来源:origin: Nextdoor/bender
/**
* Similar to {@link #findValues}, but will additionally convert
* values into Strings, calling {@link #asText}.
*/
public final List<String> findValuesAsText(String fieldName)
{
List<String> result = findValuesAsText(fieldName, null);
if (result == null) {
return Collections.emptyList();
}
return result;
}
代码示例来源:origin: com.jwebmp.jackson.core/jackson-databind
/**
* Similar to {@link #findValues}, but will additionally convert
* values into Strings, calling {@link #asText}.
*/
public final List<String> findValuesAsText(String fieldName)
{
List<String> result = findValuesAsText(fieldName, null);
if (result == null) {
return Collections.emptyList();
}
return result;
}
代码示例来源:origin: com.fasterxml.jackson.core/com.springsource.com.fasterxml.jackson.core.jackson-databind
/**
* Similar to {@link #findValues}, but will additionally convert
* values into Strings, calling {@link #asText}.
*/
public final List<String> findValuesAsText(String fieldName)
{
List<String> result = findValuesAsText(fieldName, null);
if (result == null) {
return Collections.emptyList();
}
return result;
}
代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all
/**
* Similar to {@link #findValues}, but will additionally convert
* values into Strings, calling {@link #asText}.
*/
public final List<String> findValuesAsText(String fieldName)
{
List<String> result = findValuesAsText(fieldName, null);
if (result == null) {
return Collections.emptyList();
}
return result;
}
代码示例来源:origin: baidubce/bce-sdk-java
@Override
public List<String> deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
return node.findValuesAsText("prefix");
}
}
代码示例来源:origin: dstl/baleen
private static List<String> getNames(JsonNode node) {
List<String> names = new ArrayList<>();
names.addAll(node.findValuesAsText("common"));
names.addAll(node.findValuesAsText("official"));
return names.stream().filter(s -> !Strings.isNullOrEmpty(s)).collect(Collectors.toList());
}
内容来源于网络,如有侵权,请联系作者删除!