当前位置: 首页>>代码示例>>Java>>正文


Java ObjectMapper.valueToTree方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:webinerds,项目名称:s3-proxy-chunk-upload,代码行数:20,代码来源:NotificationTask.java

示例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))
    );
}
 
开发者ID:webmate-io,项目名称:webmate-sdk-java,代码行数:18,代码来源:BrowserSessionRegressionJobInput.java

示例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))
    );
}
 
开发者ID:webmate-io,项目名称:webmate-sdk-java,代码行数:20,代码来源:BrowserSessionCrossbrowserJobInput.java

示例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());

}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:35,代码来源:ExtensionSchemaValidationTest.java

示例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);
    }
}
 
开发者ID:B2W-BIT,项目名称:restQL-core-java,代码行数:12,代码来源:QueryResponse.java

示例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());
	
}
 
开发者ID:DeanLee77,项目名称:Nadia,代码行数:33,代码来源:IterateLine_1.java

示例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())));

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:FormatIT.java

示例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)));
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:MediaIT.java


注:本文中的com.fasterxml.jackson.databind.ObjectMapper.valueToTree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。