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


Java ObjectMapper.createObjectNode方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.ObjectMapper.createObjectNode方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper.createObjectNode方法的具体用法?Java ObjectMapper.createObjectNode怎么用?Java ObjectMapper.createObjectNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.ObjectMapper的用法示例。


在下文中一共展示了ObjectMapper.createObjectNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: includeElementFieldWithWeight

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static void includeElementFieldWithWeight(String dbName, String field_name, String namespace, String elementName, double weight, String attrNS_URI, String attr_localname, String attr_value) throws Exception{

		ObjectMapper mapper = new ObjectMapper();
		//			ObjectNode mainNode = mapper.createObjectNode();
		ObjectNode childNode = mapper.createObjectNode();
		ArrayNode arrNode = mapper.createArrayNode();
		ObjectNode childNodeObject = mapper.createObjectNode();
		childNodeObject.put( "namespace-uri", namespace);
		childNodeObject.put( "localname", elementName);
		childNodeObject.put("weight", weight);
		// These 3 are new fields that have been added as of 8.0.2 from 03/20/2015 in the Management API.
		childNodeObject.put( "attribute-namespace-uri", attrNS_URI);
		childNodeObject.put( "attribute-localname", attr_localname);
		childNodeObject.put( "attribute-value", attr_value);
		arrNode.add(childNodeObject);
		childNode.putArray("included-element").addAll(arrNode);
		
		//System.out.println( childNode.toString());
		setDatabaseFieldProperties(dbName,field_name,"included-element",childNode);

	}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:22,代码来源:ConnectedRESTQA.java

示例2: arrayOfPrimitivesProducesCollectionOfWrapperTypes

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Test
public void arrayOfPrimitivesProducesCollectionOfWrapperTypes() {
    JCodeModel codeModel = new JCodeModel();
    JPackage jpackage = codeModel._package(getClass().getPackage().getName());

    ObjectMapper mapper = new ObjectMapper();

    ObjectNode itemsNode = mapper.createObjectNode();
    itemsNode.put("type", "number");

    ObjectNode propertyNode = mapper.createObjectNode();
    propertyNode.set("uniqueItems", BooleanNode.FALSE);
    propertyNode.set("items", itemsNode);

    Schema schema = mock(Schema.class);
    when(schema.getId()).thenReturn(URI.create("http://example/nonUniqueArray"));
    when(config.isUsePrimitives()).thenReturn(true);
    when(config.isUseDoubleNumbers()).thenReturn(true);

    JClass propertyType = rule.apply("fooBars", propertyNode, jpackage, schema);

    assertThat(propertyType, notNullValue());
    assertThat(propertyType.erasure(), is(codeModel.ref(List.class)));
    assertThat(propertyType.getTypeParameters().get(0).fullName(), is(Double.class.getName()));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:ArrayRuleTest.java

示例3: getAuthorisationUrl

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private String getAuthorisationUrl(BrightspaceAppContext appContext, String forwardUrl, @Nullable String postfixKey)
{
	final ObjectMapper mapper = new ObjectMapper();
	final ObjectNode stateJson = mapper.createObjectNode();
	stateJson.put(BrightspaceConnectorConstants.STATE_KEY_FORWARD_URL, forwardUrl);
	if( postfixKey != null )
	{
		stateJson.put(BrightspaceConnectorConstants.STATE_KEY_POSTFIX_KEY, postfixKey);
	}

	URI uri;
	try
	{
		uri = appContext.createWebUrlForAuthentication(
			URI.create(institutionService.institutionalise(BrightspaceConnectorConstants.AUTH_URL)),
			encrypt(mapper.writeValueAsString(stateJson)));
	}
	catch( JsonProcessingException e )
	{
		throw Throwables.propagate(e);
	}
	return uri.toString();
}
 
开发者ID:equella,项目名称:Equella,代码行数:24,代码来源:BrightspaceConnectorServiceImpl.java

示例4: jsonPorts

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Produces JSON array containing ports of the specified device.
 *
 * @param service device service
 * @param mapper  object mapper
 * @param device  infrastructure devices
 * @return JSON array
 */
public JsonNode jsonPorts(DeviceService service, ObjectMapper mapper, Device device) {
    ObjectNode result = mapper.createObjectNode();
    ArrayNode ports = mapper.createArrayNode();
    for (Port port : service.getPorts(device.id())) {
        if (isIncluded(port)) {
            ports.add(mapper.createObjectNode()
                              .put("port", portName(port.number()))
                              .put("isEnabled", port.isEnabled())
                              .put("type", port.type().toString().toLowerCase())
                              .put("portSpeed", port.portSpeed())
                              .set("annotations", annotations(mapper, port.annotations())));
        }
    }
    result.set("device", jsonForEntity(device, Device.class));
    result.set("ports", ports);
    return result;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:DevicePortsListCommand.java

示例5: handlerGroupedFields

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private ObjectNode handlerGroupedFields(ObjectMapper mapper, Field[] declaredFields,
		Map<Field, JsonNode> sortedNodes) {
	Predicate<? super Field> checkFieldSetAnnotation = field -> field.isAnnotationPresent(FieldSet.class);

	Map<String, List<JsonNode>> groupedFields = new LinkedHashMap<>();

	Arrays.stream(declaredFields).filter(checkFieldSetAnnotation)
			.forEach(field -> groupFieldsByTab(sortedNodes, field, groupedFields));

	ArrayNode groups = mapper.createArrayNode();

	ObjectNode tabsNode = mapper.createObjectNode();
	tabsNode.put(KEY_TYPE, KEY_FIELDSET);
	tabsNode.set(KEY_ITEMS, groups);
	return tabsNode;

}
 
开发者ID:JsonSchema-JavaUI,项目名称:sf-java-ui,代码行数:18,代码来源:UiFormSchemaGenerator.java

示例6: getState

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public JsonNode getState() {
	ObjectMapper mapper = new ObjectMapper();
	ObjectNode state = mapper.createObjectNode();

	state.put("name", this.getClass().getSimpleName());

	state.put("rows", this.rows);
	state.put("columns", this.columns);

	ArrayNode boardState = state.putArray("board");

	int[][] board = this.getBoard();
	for (int column = 0; column < this.columns; column++) {
		ArrayNode columnState = boardState.addArray();
		for (int row = 0; row < this.rows; row++) {
			columnState.add(board[column][row]);
		}
	}

	state.put("turn", this.currentPlayer);
	state.put("ended", this.ended);
	state.put("winner", this.winner);

	return state;
}
 
开发者ID:edwardxia,项目名称:board-server,代码行数:26,代码来源:Game.java

示例7: applyGeneratesUniqueEnumNamesForMultipleEnumNodesWithSameName

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Test
public void applyGeneratesUniqueEnumNamesForMultipleEnumNodesWithSameName() {

    Answer<String> firstArgAnswer = new FirstArgAnswer<String>();
    when(nameHelper.getFieldName(anyString(), Matchers.any(JsonNode.class))).thenAnswer(firstArgAnswer);
    when(nameHelper.replaceIllegalCharacters(anyString())).thenAnswer(firstArgAnswer);
    when(nameHelper.normalizeName(anyString())).thenAnswer(firstArgAnswer);

    JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());

    ObjectMapper objectMapper = new ObjectMapper();
    ArrayNode arrayNode = objectMapper.createArrayNode();
    arrayNode.add("open");
    arrayNode.add("closed");
    ObjectNode enumNode = objectMapper.createObjectNode();
    enumNode.put("type", "string");
    enumNode.set("enum", arrayNode);

    // We're always a string for the purposes of this test
    when(typeRule.apply("status", enumNode, jpackage, schema))
    .thenReturn(jpackage.owner()._ref(String.class));

    JType result1 = rule.apply("status", enumNode, jpackage, schema);
    JType result2 = rule.apply("status", enumNode, jpackage, schema);

    assertThat(result1.fullName(), is("org.jsonschema2pojo.rules.Status"));
    assertThat(result2.fullName(), is("org.jsonschema2pojo.rules.Status_"));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:EnumRuleTest.java

示例8: getCollectionNode

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static ObjectNode getCollectionNode(String... collections){
	ObjectMapper mapper= new ObjectMapper();
	ObjectNode mNode = mapper.createObjectNode();
	ArrayNode aNode = mapper.createArrayNode();

	for(String c : collections){
		aNode.add(c);
	}
	mNode.withArray("collection").addAll(aNode);
	return mNode;
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:12,代码来源:ConnectedRESTQA.java

示例9: parseJsonContent

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private static JsonNode parseJsonContent(byte[] rawJsonContent, ObjectMapper mapper) {
    if (rawJsonContent == null) {
        return mapper.createObjectNode();
    }
    try {
        return mapper.readTree(rawJsonContent);
    } catch (Exception e) {
        LOG.info("Unable to parse HTTP response content", e);
        return mapper.createObjectNode();
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:12,代码来源:JsonContent.java

示例10: handleActionsAnnotation

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private void handleActionsAnnotation(ObjectMapper mapper, Class<? extends Serializable> formDto,
		ArrayNode formDefinition) {
	ObjectNode groupedActionsNode = mapper.createObjectNode();

	buildActions(mapper, formDto, formDefinition);
	buildGroupedActions(mapper, formDto, groupedActionsNode, formDefinition);
}
 
开发者ID:JsonSchema-JavaUI,项目名称:sf-java-ui,代码行数:8,代码来源:UiFormSchemaGenerator.java

示例11: queryAclRule

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
/**
 * Get all ACL rules.
 * Returns array of all ACL rules.
 *
 * @return 200 OK
 */
@GET
public Response queryAclRule() {
    List<AclRule> rules = get(AclService.class).getAclRules();
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode root = mapper.createObjectNode();
    ArrayNode arrayNode = mapper.createArrayNode();
    for (AclRule rule : rules) {
        ObjectNode node = mapper.createObjectNode();
        node.put("id", rule.id().toString());
        if (rule.srcIp() != null) {
            node.put("srcIp", rule.srcIp().toString());
        }
        if (rule.dstIp() != null) {
            node.put("dstIp", rule.dstIp().toString());
        }
        if (rule.ipProto() != 0) {
            switch (rule.ipProto()) {
                case IPv4.PROTOCOL_ICMP:
                    node.put("ipProto", "ICMP");
                    break;
                case IPv4.PROTOCOL_TCP:
                    node.put("ipProto", "TCP");
                    break;
                case IPv4.PROTOCOL_UDP:
                    node.put("ipProto", "UDP");
                    break;
                default:
                    break;
            }
        }
        if (rule.dstTpPort() != 0) {
            node.put("dstTpPort", rule.dstTpPort());
        }
        node.put("action", rule.action().toString());
        arrayNode.add(node);
    }
    root.set("aclRules", arrayNode);
    return Response.ok(root.toString(), MediaType.APPLICATION_JSON_TYPE).build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:46,代码来源:AclWebResource.java

示例12: validateAndAddFieldValue

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private static void validateAndAddFieldValue(String type, String fieldValue, String fieldName, String errorMessage,
                                             JsonNode tmp) throws IllegalAccessException {
    // Add count variable for loop....
    final ObjectMapper mapper = new ObjectMapper();
    final ObjectNode parameter = mapper.createObjectNode();
    parameter.put("type", type);
    if (type == "int") {
        parameter.put("defaultValue", Integer.parseInt(fieldValue));
    } else {
        parameter.put("defaultValue", fieldValue);
    }
    ObjectNode.class.cast(tmp.get("parameters")).replace(fieldName, parameter);
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:14,代码来源:DeployUsingARMTemplateWithProgress.java

示例13: execute

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Override
protected void execute() {
    IntentMetricsService service = get(IntentMetricsService.class);

    if (outputJson()) {
        ObjectMapper mapper = new ObjectMapper()
            .registerModule(new MetricsModule(TimeUnit.SECONDS,
                                              TimeUnit.MILLISECONDS,
                                              false));
        ObjectNode result = mapper.createObjectNode();
        result = json(mapper, result, "intentSubmitted",
                      service.intentSubmittedEventMetric());
        result = json(mapper, result, "intentInstalled",
                      service.intentInstalledEventMetric());
        result = json(mapper, result, "intentFailed",
                      service.intentFailedEventMetric());
        result = json(mapper, result, "intentWithdrawRequested",
                      service.intentWithdrawRequestedEventMetric());
        result = json(mapper, result, "intentWithdrawn",
                      service.intentWithdrawnEventMetric());
        result = json(mapper, result, "intentPurged",
                      service.intentPurgedEventMetric());
        print("%s", result);
    } else {
        printEventMetric("Submitted",
                         service.intentSubmittedEventMetric());
        printEventMetric("Installed",
                         service.intentInstalledEventMetric());
        printEventMetric("Failed",
                         service.intentFailedEventMetric());
        printEventMetric("Withdraw Requested",
                         service.intentWithdrawRequestedEventMetric());
        printEventMetric("Withdrawn",
                         service.intentWithdrawnEventMetric());
        printEventMetric("Purged",
                         service.intentPurgedEventMetric());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:39,代码来源:IntentEventsMetricsCommand.java

示例14: buildValueDefinition

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private void buildValueDefinition(ObjectMapper comboMapper, ArrayNode titlesMap, String value) {
	ObjectNode entry = comboMapper.createObjectNode();
	String upperCasedValue = value.toUpperCase();
	String lowerCasedValue = value.toLowerCase();
	if (value.equals(upperCasedValue)) {
		entry.put("name", value.toLowerCase());
	} else if (value.equals(lowerCasedValue)) {
		entry.put("name", value.replace(value.substring(0, 1), value.substring(0, 1).toUpperCase()));
	} else {
		entry.put("name", value);
	}
	entry.put("value", value);
	titlesMap.add(entry);
}
 
开发者ID:JsonSchema-JavaUI,项目名称:sf-java-ui,代码行数:15,代码来源:ComboBoxGenerator.java

示例15: convert

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Override
public ObjectNode convert(ObjectMapper mapper, Limit operator, Integer inputId) {
  ObjectNode limitNode = mapper.createObjectNode();
  limitNode.put("op", "limit");
  limitNode.put("input", inputId);
  limitNode.put("first", operator.first);
  limitNode.put("last", operator.last);
  return limitNode;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:10,代码来源:Limit.java


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