com.fasterxml.jackson.databind.ObjectMapper.valueToTree()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(13.8k)|赞(0)|评价(0)|浏览(127)

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

ObjectMapper.valueToTree介绍

[英]Reverse of #treeToValue; given a value (usually bean), will construct equivalent JSON Tree representation. Functionally similar to serializing value into JSON and parsing JSON as tree, but more efficient.

NOTE: while results are usually identical to that of serialization followed by deserialization, this is not always the case. In some cases serialization into intermediate representation will retain encapsulation of things like raw value ( com.fasterxml.jackson.databind.util.RawValue) or basic node identity ( JsonNode). If so, result is a valid tree, but values are not re-constructed through actual JSON representation. So if transformation requires actual materialization of JSON (or other data format that this mapper produces), it will be necessary to do actual serialization.
[中]#树形值的倒数;给定一个值(通常是bean),将构造等价的JSON树表示。功能上类似于将值序列化为JSON并将JSON解析为树,但效率更高。
注意:虽然结果通常与序列化后反序列化的结果相同,但情况并非总是如此。在某些情况下,序列化到中间表示将保留原始值(com.fasterxml.jackson.databind.util.RawValue)或基本节点标识(JsonNode)之类的封装。若是这样,结果是一个有效的树,但值不会通过实际的JSON表示重新构造。因此,如果转换需要JSON的实际物化(或此映射程序生成的其他数据格式),则有必要进行实际的序列化。

代码示例

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeClustersResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAny(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeNetworkInterfacesResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAll(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeCacheClustersResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAll(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeReplicationTasksResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAny(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeVpnConnectionsResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAll(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeCacheClustersResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAny(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeReplicationGroupsResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAll(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeVpnConnectionsResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAny(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeReplicationGroupsResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAll(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeDBInstancesResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAny(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeTargetHealthResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAll(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeDBInstancesResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAny(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeVolumesResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAll(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeDBInstancesResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAny(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeStacksResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAll(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeStacksResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAny(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeInstancesResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAll(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeStacksResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAny(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeInstancesResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAll(expectedResult, finalResult);
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Takes the result and determines whether the state of the resource matches the expected state. To determine
 * the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
 * 
 * @param result
 *        Corresponding result of the operation
 * @return True if current state of the resource matches the expected state, False otherwise
 */
@Override
public boolean matches(DescribeReplicationTasksResult result) {
  JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
  JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
  return AcceptorPathMatcher.pathAny(expectedResult, finalResult);
}

相关文章

微信公众号

最新文章

更多

ObjectMapper类方法