本文整理汇总了Java中com.fasterxml.jackson.databind.ObjectMapper.valueToTree方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper.valueToTree方法的具体用法?Java ObjectMapper.valueToTree怎么用?Java ObjectMapper.valueToTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.ObjectMapper
的用法示例。
在下文中一共展示了ObjectMapper.valueToTree方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notify
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private void notify(String url) {
if (!url.isEmpty()) {
Logger.info("Send request to: " + url);
ObjectMapper mapper = new ObjectMapper();
ObjectNode json = mapper.createObjectNode();
JsonNode k = mapper.valueToTree(keys);
json.put("id", id)
.put("name", uploadFileName)
.put("bucket", GlobalParams.AWS_S3_BUCKET)
.put("type", type.getType())
.put("status", UploadStatus.READ.getType())
.put("keys", k);
Logger.info("Send post request: " + json);
WS.url(url).post(json);
}
}
示例2: makeInputValues
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Override
public Map<PortName, BrickValue> makeInputValues() {
JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
ObjectMapper mapper = new ObjectMapper();
List<JsonNode> compareSessionJson = new ArrayList<>();
JsonNode sessionNode = mapper.valueToTree(compareSession);
BrickValue sessionBrickValue = new BrickValue(new BrickDataType("BrowserSessionRef"), sessionNode);
compareSessionJson.add(mapper.valueToTree(sessionBrickValue));
return ImmutableMap.of(
new PortName("referenceSession"), new BrickValue(new BrickDataType("BrowserSessionRef"), jsonNodeFactory.textNode(referenceSession.getValueAsString())),
new PortName("compareSession"), new BrickValue(new BrickDataType("BrowserSessionRef"), jsonNodeFactory.textNode(compareSession.getValueAsString())),
new PortName("matchingType"), new BrickValue(new BrickDataType("String"), jsonNodeFactory.textNode("tag")),
new PortName("enabledynamicelementsfilter"), new BrickValue(new BrickDataType("Boolean"), jsonNodeFactory.booleanNode(true))
);
}
示例3: makeInputValues
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Override
public Map<PortName, BrickValue> makeInputValues() {
JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
ObjectMapper mapper = new ObjectMapper();
List<JsonNode> compareSessionJson = new ArrayList<>();
for (BrowserSessionId compareSession : compareSessions) {
JsonNode sessionNode = mapper.valueToTree(compareSession);
BrickValue sessionBrickValue = new BrickValue(new BrickDataType("BrowserSessionRef"), sessionNode);
compareSessionJson.add(mapper.valueToTree(sessionBrickValue));
}
return ImmutableMap.of(
new PortName("referenceSession"), new BrickValue(new BrickDataType("BrowserSessionRef"), jsonNodeFactory.textNode(referenceSession.toString())),
new PortName("compareSessions"), new BrickValue(new BrickDataType("List[BrowserSessionRef]"), mapper.valueToTree(compareSessionJson)),
new PortName("matchingType"), new BrickValue(new BrickDataType("String"), jsonNodeFactory.textNode("tag")),
new PortName("enabledynamicelementsfilter"), new BrickValue(new BrickDataType("Boolean"), jsonNodeFactory.booleanNode(true))
);
}
示例4: validateExtensionTest
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Test
public void validateExtensionTest() throws Exception {
ObjectMapper mapper = Json.mapper();
String syndesisExtensionSchema = "/syndesis/syndesis-extension-definition-schema.json";
JsonSchema schema = JsonSchemaFactory.byDefault().getJsonSchema("resource:" + syndesisExtensionSchema);
Extension extension = new Extension.Builder()
.extensionId("my-extension")
.name("Name")
.description("Description")
.uses(OptionalInt.empty())
.version("1.0.0")
.addAction(new ExtensionAction.Builder()
.id("action-1")
.name("action-1-name")
.description("Action 1 Description")
.actionType("extension")
.pattern(Action.Pattern.From)
.descriptor(new ExtensionDescriptor.Builder()
.entrypoint("direct:hello")
.kind(ExtensionAction.Kind.ENDPOINT)
.build())
.build())
.build();
JsonNode node = mapper.valueToTree(extension);
ProcessingReport report = schema.validate(node);
assertFalse(report.toString(), report.iterator().hasNext());
}
示例5: QueryResponse
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public QueryResponse(Map response) {
try {
ObjectMapper mapper = new ObjectMapper();
this.mapper = mapper;
this.parsed = mapper.valueToTree(response);
this.rawString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(this.parsed);
} catch (JsonProcessingException e) {
throw new ResponseParseException(e);
}
}
示例6: inferenceIterate
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private <T> void inferenceIterate(ScriptEngine nashorn, T data, int dependency)
{
ObjectMapper mapper = new ObjectMapper();
JsonNode dataJsonNode = mapper.valueToTree(data);
while(this.iterateWorkingMemory.containsKey(this.getNodeName()))
{
this.iterativeTopoSortedList.stream().forEachOrdered(node -> {
this.iterativeInclusiveList.add(node.getNodeName());
if(!hasChildren(node) && !canEvaluate(node, nashorn))
{
FactValue fv = convertFactValue(Tokenizer.getTokens(dataJsonNode.path(node.getNodeName()).asText()));
setFact(node.getVariableName(), fv);
setFact(node.getNodeName(),node.selfEvaluate(this.iterateWorkingMemory, nashorn, dependency));
forwardChaining(findNodeIndex(node.getNodeName()), nashorn);
}
else
{
if(hasChildren(node) && !this.iterateWorkingMemory.containsKey(node.getVariableName())
&& !this.iterateWorkingMemory.containsKey(node.getNodeName())
&& this.iterativeInclusiveList.contains(node.getNodeName()))
{
addChildRuleIntoInclusiveList(node);
}
}
});
}
this.outcomeList.add(((FactBooleanValue)this.iterateWorkingMemory.get(this.nodeName)).getValue());
}
示例7: valueCanBeSerializedAndDeserialized
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Test
public void valueCanBeSerializedAndDeserialized() throws NoSuchMethodException, IOException, IntrospectionException, IllegalAccessException, InvocationTargetException {
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode node = objectMapper.createObjectNode();
node.put(propertyName, jsonValue.toString());
Object pojo = objectMapper.treeToValue(node, classWithFormattedProperties);
Method getter = new PropertyDescriptor(propertyName, classWithFormattedProperties).getReadMethod();
assertThat(getter.invoke(pojo).toString(), is(equalTo(javaValue.toString())));
JsonNode jsonVersion = objectMapper.valueToTree(pojo);
assertThat(jsonVersion.get(propertyName).asText(), is(equalTo(jsonValue.toString())));
}
示例8: roundTripAssertions
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static void roundTripAssertions( ObjectMapper objectMapper, String propertyName, String jsonValue, Object javaValue) throws Exception {
ObjectNode node = objectMapper.createObjectNode();
node.put(propertyName, jsonValue);
Object pojo = objectMapper.treeToValue(node, classWithMediaProperties);
Method getter = new PropertyDescriptor(propertyName, classWithMediaProperties).getReadMethod();
assertThat(getter.invoke(pojo), is(equalTo(javaValue)));
JsonNode jsonVersion = objectMapper.valueToTree(pojo);
assertThat(jsonVersion.get(propertyName).asText(), is(equalTo(jsonValue)));
}