org.codehaus.jackson.node.ObjectNode.remove()方法的使用及代码示例

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

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

ObjectNode.remove介绍

[英]Method for removing field entry from this ObjectNode. Will return value of the field, if such field existed; null if not.
[中]用于从此ObjectNode中删除字段项的方法。将返回该字段的值(如果该字段存在);如果不是,则为空。

代码示例

代码示例来源:origin: kaaproject/kaa

private Schema parseDependencies(CTLSchemaDto schema, final Schema.Parser parser) throws
    Exception {
 if (schema.getDependencySet() != null) {
  for (CTLSchemaDto dependency : schema.getDependencySet()) {
   this.parseDependencies(dependency, parser);
  }
 }
 ObjectNode object = new ObjectMapper().readValue(schema.getBody(), ObjectNode.class);
 object.remove(DEPENDENCIES);
 String body = new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(object);
 return parser.parse(body);
}

代码示例来源:origin: kaaproject/kaa

/**
  * Removes UUIDs from a json tree.
  *
  * @param json json tree node
  */
 public static void removeUuids(JsonNode json) {
  boolean containerWithId = json.isContainerNode() && json.has(UUID_FIELD);
  boolean isArray = json.isArray();
  boolean childIsNotArray = !(json.size() == 1 && json.getElements().next().isArray());

  if (containerWithId && !isArray && childIsNotArray) {
   ((ObjectNode) json).remove(UUID_FIELD);
  }

  for (JsonNode node : json) {
   if (node.isContainerNode()) {
    removeUuids(node);
   }
  }
 }
}

代码示例来源:origin: com.github.foodev/jsondiff

@Override
public void remove(String key) {
  wrapped.remove(key);
}

代码示例来源:origin: algesten/jsondiff

@Override
public void remove(String key) {
  wrapped.remove(key);
}

代码示例来源:origin: eBay/YiDB

private void createJsonNode(MetaClass metadata) {
  currentNode = mapper.valueToTree(metadata);
  currentNode.remove("fields");
  currentNode.remove("options");
  currentNode.put("fields", JsonNodeFactory.instance.objectNode());
}

代码示例来源:origin: eBay/YiDB

private void removeFieldProperty(String fieldName, String propertyName) {
  FieldProperty fp = FieldProperty.fromQueryName(propertyName);
  CheckConditions.checkArgument(fp != null, MessageFormat.format("field property %s not found!", propertyName));
  String propertyValueDbName = fieldName + PROPERTY_CONNECTOR + propertyName;
  getNode().remove(propertyValueDbName);
}

代码示例来源:origin: eBay/YiDB

@Override
public void removeField(String fieldName) {
  getNode().remove(fieldName);
  for (FieldProperty fp : FieldProperty.values()) {
    removeFieldProperty(fieldName, fp.getName());
  }
}

代码示例来源:origin: de.mhus.lib/mhu-lib-core

@Override
public void removeProperty(String name) {
  JsonNode child = node.get(name);
  if (child!=null && !child.isArray() && !child.isObject())
    getNode().remove(name);
}

代码示例来源:origin: sirensolutions/siren

private void convertTetheredCable(final JsonNode obj) {
 final Iterator<JsonNode> nodes = obj.path("Connector").iterator();
 while (nodes.hasNext()) {
  final ObjectNode node = (ObjectNode) nodes.next();
  final JsonNode current = node.path("TetheredCable");
  if (!current.isMissingNode() && !current.isNull()) {
   final int value = Integer.parseInt(current.asText());
   node.put("TetheredCable", value);
  }
  if (current.isNull()) {
   node.remove("TetheredCable");
  }
 }
}

代码示例来源:origin: rdelbru/SIREn

private void convertLongitude(final JsonNode obj) {
 final ObjectNode node = (ObjectNode) obj.path("ChargeDeviceLocation");
 final JsonNode current = node.path("Longitude");
 if (!current.isMissingNode() && !current.isNull()) {
  final double value = Double.parseDouble(current.asText());
  node.put("Longitude", value);
 }
 if (current.isNull()) {
  node.remove("Longitude");
 }
}

代码示例来源:origin: sirensolutions/siren

private void convertLongitude(final JsonNode obj) {
 final ObjectNode node = (ObjectNode) obj.path("ChargeDeviceLocation");
 final JsonNode current = node.path("Longitude");
 if (!current.isMissingNode() && !current.isNull()) {
  final double value = Double.parseDouble(current.asText());
  node.put("Longitude", value);
 }
 if (current.isNull()) {
  node.remove("Longitude");
 }
}

代码示例来源:origin: sirensolutions/siren

private void convertLatitude(final JsonNode obj) {
 final ObjectNode node = (ObjectNode) obj.path("ChargeDeviceLocation");
 final JsonNode current = node.path("Latitude");
 if (!current.isMissingNode() && !current.isNull()) {
  final double value = Double.parseDouble(current.asText());
  node.put("Latitude", value);
 }
 if (current.isNull()) {
  node.remove("Latitude");
 }
}

代码示例来源:origin: rdelbru/SIREn

private void convertLatitude(final JsonNode obj) {
 final ObjectNode node = (ObjectNode) obj.path("ChargeDeviceLocation");
 final JsonNode current = node.path("Latitude");
 if (!current.isMissingNode() && !current.isNull()) {
  final double value = Double.parseDouble(current.asText());
  node.put("Latitude", value);
 }
 if (current.isNull()) {
  node.remove("Latitude");
 }
}

代码示例来源:origin: apache/samza

/**
 * Given a {@link ContainerModel} JSON with neither a processor-id nor a container-id, deserialization should fail.
 */
@Test(expected = SamzaException.class)
public void testDeserializeContainerModelMissingProcessorIdAndContainerId() throws IOException {
 ObjectNode jobModelJson = buildJobModelJson();
 ObjectNode containerModelJson = (ObjectNode) jobModelJson.get("containers").get("1");
 containerModelJson.remove("processor-id");
 deserializeFromObjectNode(jobModelJson);
}

代码示例来源:origin: rdelbru/SIREn

private void convertDeviceControllerWebsite(final JsonNode obj) {
 final ObjectNode node = (ObjectNode) obj.path("DeviceController");
 final JsonNode current = node.path("Website");
 if (!current.isMissingNode() && !current.isNull()) {
  node.put("Website", this.createValueDatatype("uri", current.asText()));
 }
 if (current.isNull()) {
  node.remove("Website");
 }
}

代码示例来源:origin: rdelbru/SIREn

private void convertDeviceOwnerWebsite(final JsonNode obj) {
 final ObjectNode node = (ObjectNode) obj.path("DeviceOwner");
 final JsonNode current = node.path("Website");
 if (!current.isMissingNode() && !current.isNull()) {
  node.put("Website", this.createValueDatatype("uri", current.asText()));
 }
 if (current.isNull()) {
  node.remove("Website");
 }
}

代码示例来源:origin: sirensolutions/siren

private void convertDeviceControllerWebsite(final JsonNode obj) {
 final ObjectNode node = (ObjectNode) obj.path("DeviceController");
 final JsonNode current = node.path("Website");
 if (!current.isMissingNode() && !current.isNull()) {
  node.put("Website", this.createValueDatatype("uri", current.asText()));
 }
 if (current.isNull()) {
  node.remove("Website");
 }
}

代码示例来源:origin: sirensolutions/siren

private void convertDeviceOwnerWebsite(final JsonNode obj) {
 final ObjectNode node = (ObjectNode) obj.path("DeviceOwner");
 final JsonNode current = node.path("Website");
 if (!current.isMissingNode() && !current.isNull()) {
  node.put("Website", this.createValueDatatype("uri", current.asText()));
 }
 if (current.isNull()) {
  node.remove("Website");
 }
}

代码示例来源:origin: apache/samza

/**
 * Given a {@link ContainerModel} JSON with only an "id" field, deserialization should fail.
 * This verifies that even though {@link ContainerModel} has a getId method, the "id" field is not used, since
 * "processor-id" is the field that is supposed to be used.
 */
@Test(expected = SamzaException.class)
public void testDeserializeContainerModelIdFieldOnly() throws IOException {
 ObjectNode jobModelJson = buildJobModelJson();
 ObjectNode containerModelJson = (ObjectNode) jobModelJson.get("containers").get("1");
 containerModelJson.remove("processor-id");
 containerModelJson.put("id", 1);
 deserializeFromObjectNode(jobModelJson);
}

代码示例来源:origin: apache/samza

/**
 * Given a {@link ContainerModel} JSON without a processor-id but with a container-id, deserialization should use the
 * container-id to calculate the processor-id.
 */
@Test
public void testDeserializeContainerModelOnlyContainerId() throws IOException {
 ObjectNode jobModelJson = buildJobModelJson();
 ObjectNode containerModelJson = (ObjectNode) jobModelJson.get("containers").get("1");
 containerModelJson.remove("processor-id");
 containerModelJson.put("container-id", 1);
 assertEquals(this.jobModel, deserializeFromObjectNode(jobModelJson));
}

相关文章