com.fasterxml.jackson.databind.node.ObjectNode.putObject()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(203)

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

ObjectNode.putObject介绍

[英]Method that will construct an ObjectNode and add it as a field of this ObjectNode, replacing old value, if any.

NOTE: Unlike all put(...) methods, return value is NOT this ObjectNode, but the newly createdObjectNode instance.
[中]方法,该方法将构造一个ObjectNode并将其添加为此ObjectNode的字段,替换旧值(如果有)。
注:与所有put不同(…)方法,返回值不是这个ObjectNode,而是新创建的ObjectNode实例。

代码示例

代码示例来源:origin: Vedenin/useful-java-links

/**
   * Example to writeJson using TreeModel
   */
  private static void writeJson() throws IOException {
    OutputStream outputStream = new ByteArrayOutputStream();

    ObjectMapper mapper = new ObjectMapper();
    ObjectNode rootNode = mapper.createObjectNode();
    rootNode.put("message", "Hi");
    ObjectNode childNode = rootNode.putObject("place");
    childNode.put("name", "World!");
    mapper.writeValue(outputStream, childNode);

    System.out.println(outputStream.toString()); // print "{"message":"Hi","place":{"name":"World!"}}"
  }
}

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

protected ObjectNode createOrGetBpmnNode(ObjectNode infoNode) {
 if (!infoNode.has(BPMN_NODE)) {
  infoNode.putObject(BPMN_NODE);
 }
 return (ObjectNode) infoNode.get(BPMN_NODE);
}

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

protected ObjectNode createOrGetLocalizationNode(ObjectNode infoNode) {
 if (!infoNode.has(LOCALIZATION_NODE)) {
  infoNode.putObject(LOCALIZATION_NODE);
 }
 return (ObjectNode) infoNode.get(LOCALIZATION_NODE);
}

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

protected void setLocalizationProperty(String language, String id, String propertyName, String propertyValue, ObjectNode infoNode) {
 ObjectNode localizationNode = createOrGetLocalizationNode(infoNode);
 if (!localizationNode.has(language)) {
  localizationNode.putObject(language);
 }
 
 ObjectNode languageNode = (ObjectNode) localizationNode.get(language);
 if (!languageNode.has(id)) {
  languageNode.putObject(id);
 }
 
 ((ObjectNode) languageNode.get(id)).put(propertyName, propertyValue);
}

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

protected void setElementProperty(String id, String propertyName, JsonNode propertyValue, ObjectNode infoNode) {
 ObjectNode bpmnNode = createOrGetBpmnNode(infoNode);
 if (!bpmnNode.has(id)) {
  bpmnNode.putObject(id);
 }
 
 ((ObjectNode) bpmnNode.get(id)).set(propertyName, propertyValue);
}

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

protected void setElementProperty(String id, String propertyName, String propertyValue, ObjectNode infoNode) {
 ObjectNode bpmnNode = createOrGetBpmnNode(infoNode);
 if (!bpmnNode.has(id)) {
  bpmnNode.putObject(id);
 }
 
 ((ObjectNode) bpmnNode.get(id)).put(propertyName, propertyValue);
}

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

private Response jsonSuccessResponse(Object result, float took) {
    ObjectNode json = JsonNodeFactory.instance.objectNode();
    json.putPOJO("polygons", result);
    // If you replace GraphHopper with your own brand name, this is fine.
    // Still it would be highly appreciated if you mention us in your about page!
    final ObjectNode info = json.putObject("info");
    info.putArray("copyrights")
        .add("GraphHopper")
        .add("OpenStreetMap contributors");
    info.put("took", Math.round(took * 1000));
    return Response.ok(json).build();
  }
}

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

final ObjectNode info = json.putObject("info");
info.putArray("copyrights")
    .add("GraphHopper")

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

@Override
public ObjectNode toJSON() {
  JsonNodeFactory nf = JsonNodeFactory.instance;
  ObjectNode json = nf.objectNode();
  json.put("format", "json");
  json.put("entity_type", entityType.getName());
  if (!attributes.isEmpty()) {
    ObjectNode attrNode = json.putObject("attributes");
    for (Map.Entry<String,TypedName<?>> attr: attributes.entrySet()) {
      ObjectNode an = attrNode.putObject(attr.getKey());
      an.put("name", attr.getValue().getName());
      an.put("type", TypeUtils.makeTypeName(attr.getValue().getType()));
    }
  }
  return json;
}

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

ObjectNode cols = json.putObject("columns");
for (Map.Entry<String,TypedName<?>> colE: labeledColumns.entrySet()) {
  ObjectNode colNode = cols.putObject(colE.getKey());
  colNode.put("name", colE.getValue().getName());
  colNode.put("type", TypeUtils.makeTypeName(colE.getValue().getType()));

代码示例来源:origin: org.flowable/flowable-engine

protected ObjectNode createOrGetLocalizationNode(ObjectNode infoNode) {
  if (!infoNode.has(LOCALIZATION_NODE)) {
    infoNode.putObject(LOCALIZATION_NODE);
  }
  return (ObjectNode) infoNode.get(LOCALIZATION_NODE);
}

代码示例来源:origin: io.micronaut/runtime

private JsonNode node(JsonNode node) {
    if (node instanceof ObjectNode) {
      return ((ObjectNode) node).putObject(currentFieldName);
    } else if (node instanceof ArrayNode) {
      return ((ArrayNode) node).addObject();
    } else {
      return JsonNodeFactory.instance.objectNode();
    }
  }
}

代码示例来源:origin: org.activiti/activiti-engine

protected ObjectNode createOrGetLocalizationNode(ObjectNode infoNode) {
 if (infoNode.has(LOCALIZATION_NODE) == false) {
  infoNode.putObject(LOCALIZATION_NODE);
 }
 return (ObjectNode) infoNode.get(LOCALIZATION_NODE);
}

代码示例来源:origin: org.activiti/activiti-engine

protected void setLocalizationProperty(String language, String id, String propertyName, String propertyValue, ObjectNode infoNode) {
 ObjectNode localizationNode = createOrGetLocalizationNode(infoNode);
 if (localizationNode.has(language) == false) {
  localizationNode.putObject(language);
 }
 
 ObjectNode languageNode = (ObjectNode) localizationNode.get(language);
 if (languageNode.has(id) == false) {
  languageNode.putObject(id);
 }
 
 ((ObjectNode) languageNode.get(id)).put(propertyName, propertyValue);
}

代码示例来源:origin: org.flowable/flowable-engine

protected void setLocalizationProperty(String language, String id, String propertyName, String propertyValue, ObjectNode infoNode) {
  ObjectNode localizationNode = createOrGetLocalizationNode(infoNode);
  if (!localizationNode.has(language)) {
    localizationNode.putObject(language);
  }
  ObjectNode languageNode = (ObjectNode) localizationNode.get(language);
  if (!languageNode.has(id)) {
    languageNode.putObject(id);
  }
  ((ObjectNode) languageNode.get(id)).put(propertyName, propertyValue);
}

代码示例来源:origin: org.activiti/activiti-engine

protected void setElementProperty(String id, String propertyName, JsonNode propertyValue, ObjectNode infoNode) {
 ObjectNode bpmnNode = createOrGetBpmnNode(infoNode);
 if (bpmnNode.has(id) == false) {
  bpmnNode.putObject(id);
 }
 
 ((ObjectNode) bpmnNode.get(id)).set(propertyName, propertyValue);
}

代码示例来源:origin: org.flowable/flowable-engine

protected void setElementProperty(String id, String propertyName, String propertyValue, ObjectNode infoNode) {
  ObjectNode bpmnNode = createOrGetBpmnNode(infoNode);
  if (!bpmnNode.has(id)) {
    bpmnNode.putObject(id);
  }
  ((ObjectNode) bpmnNode.get(id)).put(propertyName, propertyValue);
}

代码示例来源:origin: org.activiti/activiti-engine

protected void setElementProperty(String id, String propertyName, String propertyValue, ObjectNode infoNode) {
 ObjectNode bpmnNode = createOrGetBpmnNode(infoNode);
 if (bpmnNode.has(id) == false) {
  bpmnNode.putObject(id);
 }
 
 ((ObjectNode) bpmnNode.get(id)).put(propertyName, propertyValue);
}

代码示例来源:origin: org.onosproject/onos-core-common

@Override
  public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
    OduSignalId oduSignalId = ((OduSignalIdCriterion) criterion).oduSignalId();
    ObjectNode child = root.putObject(CriterionCodec.ODU_SIGNAL_ID);
    child.put(CriterionCodec.TRIBUTARY_PORT_NUMBER, oduSignalId.tributaryPortNumber());
    child.put(CriterionCodec.TRIBUTARY_SLOT_LEN, oduSignalId.tributarySlotLength());
    child.put(CriterionCodec.TRIBUTARY_SLOT_BITMAP, HexString.toHexString(oduSignalId.tributarySlotBitmap()));
    return root;
  }
}

代码示例来源:origin: org.onosproject/onos-core-common

@Override
  public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
    OchSignal ochSignal = ((OchSignalCriterion) criterion).lambda();
    ObjectNode child = root.putObject(CriterionCodec.OCH_SIGNAL_ID);
    child.put(CriterionCodec.GRID_TYPE, ochSignal.gridType().name());
    child.put(CriterionCodec.CHANNEL_SPACING, ochSignal.channelSpacing().name());
    child.put(CriterionCodec.SPACING_MULIPLIER, ochSignal.spacingMultiplier());
    child.put(CriterionCodec.SLOT_GRANULARITY, ochSignal.slotGranularity());
    return root;
  }
}

相关文章

微信公众号

最新文章

更多