org.codehaus.jackson.JsonNode.getValueAsText()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中org.codehaus.jackson.JsonNode.getValueAsText()方法的一些代码示例,展示了JsonNode.getValueAsText()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.getValueAsText()方法的具体详情如下:
包路径:org.codehaus.jackson.JsonNode
类名称:JsonNode
方法名:getValueAsText

JsonNode.getValueAsText介绍

[英]Method that will return valid String representation of the container value, if the node is a value node (method #isValueNode returns true), otherwise null.

Note: to serialize nodes of any type, you should call #toString instead.
[中]方法,该方法将返回容器值的有效字符串表示形式,如果该节点是值节点(方法#isValueNode返回true),否则为null。
注意:要序列化任何类型的节点,应该调用#toString。

代码示例

代码示例来源:origin: linkedin/parseq

private static JsonNode getField(final JsonNode node, final String fieldName) throws IOException {
  final JsonNode field = node.get(fieldName);
  if (field == null) {
   throw new IOException("Missing field: '" + fieldName + "' in " + node.getValueAsText());
  }
  return field;
 }
}

代码示例来源:origin: apache/incubator-gobblin

private List<String> getDeltaFieldNamesForNewSchema(Schema originalSchema) {
 List<String> deltaFields = new ArrayList<>();
 for (Field field : originalSchema.getFields()) {
  String deltaAttributeField = field.getJsonProp(this.attributeField).getValueAsText();
  ObjectNode objectNode = getDeltaPropValue(deltaAttributeField);
  if (objectNode == null || objectNode.get(this.deltaPropName) == null) {
   continue;
  }
  if (Boolean.parseBoolean(objectNode.get(this.deltaPropName).toString())) {
   deltaFields.add(field.name());
  }
 }
 log.info("Will use delta fields: " + deltaFields);
 return deltaFields;
}

代码示例来源:origin: voldemort/voldemort

case FIXED:
  if(defaultJson.isTextual()) {
    byte[] fixed = defaultJson.getValueAsText().getBytes();
    if(fixed.length == schema.getFixedSize()) {
      break;

代码示例来源:origin: se.vgregion.pubsubhubbub/pubsubhubbub-hub-composite-twitter

@Override
public String getContent() {
  return node.getValueAsText();
}

代码示例来源:origin: net.sf.sido/sido

public static String getString(JsonNode jNode, String name) {
  JsonNode jField = jNode.get(name);
  if (jField != null) {
    return jField.getValueAsText();
  } else {
    return null;
  }
}

代码示例来源:origin: lordofthejars/nosql-unit

private String getImplementationValue(JsonNode definedObject) {
  JsonNode implementationNode = definedObject.get(IMPLEMENTATION_TOKEN);
  if (implementationNode != null) {
    return implementationNode.getValueAsText();
  } else {
    throw new IllegalArgumentException("No implementation class has been provided.");
  }
}

代码示例来源:origin: com.lordofthejars/nosqlunit-neo4j

private String getImplementationValue(JsonNode definedObject) {
  JsonNode implementationNode = definedObject.get(IMPLEMENTATION_TOKEN);
  if (implementationNode != null) {
    return implementationNode.getValueAsText();
  } else {
    throw new IllegalArgumentException("No implementation class has been provided.");
  }
}

代码示例来源:origin: com.linkedin.parseq/parseq

private static JsonNode getField(final JsonNode node, final String fieldName) throws IOException {
  final JsonNode field = node.get(fieldName);
  if (field == null) {
   throw new IOException("Missing field: '" + fieldName + "' in " + node.getValueAsText());
  }
  return field;
 }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.clients

/**
 * @return total number of bundles.
 */
public int getTotalNumOfBundles() {
  return Integer.parseInt(status.get(0).getValueAsText());
}

代码示例来源:origin: NGDATA/hbase-indexer

private String[] getStringArrayProperty(ObjectNode node, String property) {
  ArrayNode arrayNode = JsonUtil.getArray(node, property, null);
  if (arrayNode == null)
    return null;
  else {
    List<String> strings = new ArrayList<String>();
    for (JsonNode jsonNode : arrayNode) {
      strings.add(jsonNode.getValueAsText());
    }
    return strings.toArray(new String[strings.size()]);
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.clients

/**
 * @return the status message of the bundle context
 * @throws ClientException if the request cannot be completed
 */
public String getStatusMessage() throws ClientException {
  if(root.get("status") == null)
    throw new ClientException("No Status message returned!");
  return root.get("status").getValueAsText();
}

代码示例来源:origin: de.mhus.lib/mhu-lib-core

@SuppressWarnings("deprecation")
@Override
public Object getProperty(String name) {
  JsonNode child = node.get(name);
  if (child==null) return null;
  return child.getValueAsText();
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.clients

/**
 * @return the number of installed components
 * @throws ClientException if the info cannot be retrieved
 */
public int getNumberOfInstalledComponents() throws ClientException {
  if(root.get("status") == null)
    throw new ClientException("Number of installed Components not defined!");
  return Integer.parseInt(root.get("status").getValueAsText());
}

代码示例来源:origin: com.ngdata/hbase-indexer-model

private String[] getStringArrayProperty(ObjectNode node, String property) {
  ArrayNode arrayNode = JsonUtil.getArray(node, property, null);
  if (arrayNode == null)
    return null;
  else {
    List<String> strings = new ArrayList<String>();
    for (JsonNode jsonNode : arrayNode) {
      strings.add(jsonNode.getValueAsText());
    }
    return strings.toArray(new String[strings.size()]);
  }
}

代码示例来源:origin: NGDATA/hbase-indexer

private String getCollectionConfigPath(String collectionName) {
  try {
    byte[] data = zk.getData("/collections/" + collectionName, false, null);
    ObjectMapper objectMapper = new ObjectMapper();
    JsonParser jsonParser = objectMapper.getJsonFactory().createJsonParser(data);
    JsonNode collectionNode = objectMapper.readTree(jsonParser);
    return ZkConfigManager.CONFIGS_ZKNODE + "/" + collectionNode.get(ZkController.CONFIGNAME_PROP).getValueAsText();
  } catch (Exception e) {
    // TODO Better exception handling here
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.ngdata/hbase-indexer-common

private String getCollectionConfigPath(String collectionName) {
  try {
    byte[] data = zk.getData("/collections/" + collectionName, false, null);
    ObjectMapper objectMapper = new ObjectMapper();
    JsonParser jsonParser = objectMapper.getJsonFactory().createJsonParser(data);
    JsonNode collectionNode = objectMapper.readTree(jsonParser);
    return ZkConfigManager.CONFIGS_ZKNODE + "/" + collectionNode.get(ZkController.CONFIGNAME_PROP).getValueAsText();
  } catch (Exception e) {
    // TODO Better exception handling here
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.ngdata/hbase-indexer-common

public static List<String> getStrings(JsonNode node, String prop, List<String> defaultValue) throws JsonFormatException {
    ArrayNode arrayNode = getArray(node, prop, null);
    if (arrayNode == null || arrayNode.isNull()) {
      return defaultValue;
    }
    List<String> elements = new ArrayList<String>();
    Iterator<JsonNode> elementItr = arrayNode.getElements();
    while (elementItr.hasNext()) {
      elements.add(elementItr.next().getValueAsText());
    }
    return elements;
  }
}

代码示例来源:origin: net.sf.sido/sido

protected void readConstraint(SiDOSchema sido, DataObject property, JsonNode jConstraint) {
  String id = getString(jConstraint, "type", true, null);
  DataObject constraint = sido.createConstraint(property, id);
  // All parameters
  Iterator<String> fieldNames = jConstraint.getFieldNames();
  while (fieldNames.hasNext()) {
    String fieldName = fieldNames.next();
    if (!"type".equals(fieldName)) {
      sido.setConstraintParam(constraint, fieldName, jConstraint.get(fieldName).getValueAsText());
    }
  }
}

代码示例来源:origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

public String asArg() {
  if (isValue()) {
    return asJsonNode().getValueAsText();
  } else {
    return asJsonNode().toString();
  }
}

代码示例来源:origin: org.apache.isis.viewer/json-applib

public String asArg() {
  if (isValue()) {
    return asJsonNode().getValueAsText();
  } else {
    return asJsonNode().toString();
  }
}

相关文章