本文整理汇总了Java中com.fasterxml.jackson.databind.JsonNode.deepCopy方法的典型用法代码示例。如果您正苦于以下问题:Java JsonNode.deepCopy方法的具体用法?Java JsonNode.deepCopy怎么用?Java JsonNode.deepCopy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.JsonNode
的用法示例。
在下文中一共展示了JsonNode.deepCopy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
JsonNode apply(final JsonNode node) {
JsonNode source = node.at(from);
if (source.isMissingNode()) {
throw new JsonPatchException("non-existent source path: " + from);
}
if (path.toString().isEmpty()) {
return source;
}
final JsonNode targetParent = ensureTargetParent(node, path);
source = source.deepCopy();
return targetParent.isArray() ? AddOperation.addToArray(path, node, source)
: AddOperation.addToObject(path, node, source);
}
示例2: apply
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
* Applies this patch to a JSON value.
*
* @param node the value to apply the patch to
* @return the patched JSON value
* @throws JsonPatchException failed to apply patch
* @throws NullPointerException input is null
*/
public JsonNode apply(final JsonNode node) {
requireNonNull(node, "node");
JsonNode ret = node.deepCopy();
for (final JsonPatchOperation operation : operations) {
ret = operation.apply(ret);
}
return ret;
}
示例3: SafeReplaceOperation
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@JsonCreator
SafeReplaceOperation(@JsonProperty("path") final JsonPointer path,
@JsonProperty("oldValue") JsonNode oldValue,
@JsonProperty("value") JsonNode newValue) {
super("safeReplace", path);
this.oldValue = oldValue.deepCopy();
this.newValue = newValue.deepCopy();
}
示例4: apply
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
* Applies this schema rule to take the required code generation steps.
* <p>
* A Java {@link Enum} is created, with constants for each of the enum
* values present in the schema. The enum name is derived from the nodeName,
* and the enum type itself is created as an inner class of the owning type.
* In the rare case that no owning type exists (the enum is the root of the
* schema), then the enum becomes a public class in its own right.
* <p>
* The actual JSON value for each enum constant is held in a property called
* "value" in the generated type. A static factory method
* <code>fromValue(String)</code> is added to the generated enum, and the
* methods are annotated to allow Jackson to marshal/unmarshal values
* correctly.
*
* @param nodeName
* the name of the property which is an "enum"
* @param node
* the enum node
* @param container
* the class container (class or package) to which this enum
* should be added
* @return the newly generated Java type that was created to represent the
* given enum
*/
@Override
public JType apply(String nodeName, JsonNode node, JClassContainer container, Schema schema) {
JDefinedClass _enum;
try {
_enum = createEnum(node, nodeName, container);
} catch (ClassAlreadyExistsException e) {
return e.getExistingClass();
}
schema.setJavaTypeIfEmpty(_enum);
if (node.has("javaInterfaces")) {
addInterfaces(_enum, node.get("javaInterfaces"));
}
// copy our node; remove the javaType as it will throw off the TypeRule for our case
ObjectNode typeNode = (ObjectNode)node.deepCopy();
typeNode.remove("javaType");
// If type is specified on the enum, get a type rule for it. Otherwise, we're a string.
// (This is different from the default of Object, which is why we don't do this for every case.)
JType backingType = node.has("type") ?
ruleFactory.getTypeRule().apply(nodeName, typeNode, container, schema) :
container.owner().ref(String.class);
JFieldVar valueField = addValueField(_enum, backingType);
// override toString only if we have a sensible string to return
if(isString(backingType)){
addToString(_enum, valueField);
}
addValueMethod(_enum, valueField);
addEnumConstants(node.path("enum"), _enum, node.path("javaEnumNames"), backingType);
addFactoryMethod(_enum, backingType);
return _enum;
}
示例5: propertyNodeForComparisson
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static ObjectNode propertyNodeForComparisson(final JsonNode propertyDefinition) {
final ObjectNode propertyDefinitionForComparisson = propertyDefinition.deepCopy();
propertyDefinitionForComparisson.remove(Arrays.asList("tags", "componentProperty"));
return propertyDefinitionForComparisson;
}
示例6: PathValueOperation
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
* Creates a new instance.
*
* @param op operation name
* @param path affected path
* @param value JSON value
*/
PathValueOperation(final String op, final JsonPointer path, final JsonNode value) {
super(op, path);
this.value = value.deepCopy();
}