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

x33g5p2x  于2022-01-21 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(143)

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

JsonNodeFactory.pojoNode介绍

[英]Factory method for constructing a wrapper for POJO ("Plain Old Java Object") objects; these will get serialized using data binding, usually as JSON Objects, but in some cases as JSON Strings or other node types.
[中]用于构建POJO(“普通旧Java对象”)对象包装器的工厂方法;这些将使用数据绑定进行序列化,通常作为JSON对象,但在某些情况下作为JSON字符串或其他节点类型。

代码示例

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

@Override
public final ValueNode pojoNode(Object pojo) { return _nodeFactory.pojoNode(pojo); }

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

protected final JsonNode _fromEmbedded(JsonParser p, DeserializationContext ctxt,
      JsonNodeFactory nodeFactory) throws IOException
  {
    Object ob = p.getEmbeddedObject();
    if (ob == null) { // should this occur?
      return nodeFactory.nullNode();
    }
    Class<?> type = ob.getClass();
    if (type == byte[].class) { // most common special case
      return nodeFactory.binaryNode((byte[]) ob);
    }
    // [databind#743]: Don't forget RawValue
    if (ob instanceof RawValue) {
      return nodeFactory.rawValueNode((RawValue) ob);
    }
    if (ob instanceof JsonNode) {
      // [databind#433]: but could also be a JsonNode hiding in there!
      return (JsonNode) ob;
    }
    // any other special handling needed?
    return nodeFactory.pojoNode(ob);
  }
}

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

@Override
public final ValueNode pojoNode(Object pojo) { return _nodeFactory.pojoNode(pojo); }

代码示例来源:origin: com.jwebmp.jackson.core/jackson-databind

@Override
public final ValueNode pojoNode(Object pojo) { return _nodeFactory.pojoNode(pojo); }

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

@Override
public final ValueNode pojoNode(Object pojo) { return _nodeFactory.pojoNode(pojo); }

代码示例来源:origin: Nextdoor/bender

@Override
public final ValueNode pojoNode(Object pojo) { return _nodeFactory.pojoNode(pojo); }

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

/**
 * @deprecated Since 2.3 Use {@link #pojoNode} instead.
 */
@Deprecated
public final POJONode POJONode(Object pojo) { return (POJONode) _nodeFactory.pojoNode(pojo); }

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

/**
 * @deprecated Since 2.3 Use {@link #pojoNode} instead.
 */
@Deprecated
public final POJONode POJONode(Object pojo) { return (POJONode) _nodeFactory.pojoNode(pojo); }

代码示例来源:origin: com.vaadin/vaadin-charts-flow

private void addValue(ArrayNode data, Optional<Object> value) {
  if (value.isPresent()) {
    ValueNode node = JsonNodeFactory.instance.pojoNode(value.get());
    data.add(node);
  }
}

代码示例来源:origin: com.vaadin/vaadin-charts-flow

private void addNamedValue(ObjectNode data, String name,
      Optional<Object> value) {
    if (value.isPresent()) {
      ValueNode node = JsonNodeFactory.instance.pojoNode(value.get());
      data.set(name, node);

    }
  }
}

代码示例来源:origin: edu.psu.swe.commons/commons-jaxrs

/**
 * Create a `test` PatchOperation for Objects.
 * @param jsonPointer
 * @param value
 * @return
 */
public static PatchOperation test(JsonPointer jsonPointer, Object value) {
 return test(jsonPointer, JsonNodeFactory.instance.pojoNode(value));
}

代码示例来源:origin: edu.psu.swe.commons/commons-jaxrs

/**
 * Create a `replace` PatchOperation for Objects.
 * @param jsonPointer
 * @param value
 * @return
 */
public static PatchOperation replace(JsonPointer jsonPointer, Object value) {
 return replace(jsonPointer, JsonNodeFactory.instance.pojoNode(value));
}

代码示例来源:origin: edu.psu.swe.commons/commons-jaxrs

/**
 * Create an `add` PatchOperation for Objects.
 * @param jsonPointer
 * @param value
 * @return
 */
public static PatchOperation add(JsonPointer jsonPointer, Object value) {
 return add(jsonPointer, JsonNodeFactory.instance.pojoNode(value));
}

代码示例来源:origin: edu.psu.swe.commons/commons-jaxrs

/**
 * Create a `remove` PatchOperation for Objects where the last property is an index into a Set.
 * @param jsonPointer
 * @param value
 * @return
 */
public static PatchOperation remove(JsonPointer jsonPointer, Object value) {
 return new PatchOperation(Type.REMOVE, jsonPointer, JsonNodeFactory.instance.pojoNode(value));
}

代码示例来源:origin: net.apexes.wsonrpc/wsonrpc-core

@Override
public JsonRpcResponse createResponse(String id, Object result) {
  JsonNode resultNode = objectMapper.getNodeFactory().pojoNode(result);
  return createResponse(id, "result", resultNode);
}

代码示例来源:origin: infiniteautomation/ma-core-public

@Override
  public JsonNode getExplainInfo() {
    Map<String, Object> info = new HashMap<>();
    info.put("rql", new ParameterInfo("String", true, null, new TranslatableMessage("common.default", "RQL query for data points to return events for")));
    return JsonNodeFactory.instance.pojoNode(info);
  }
}

代码示例来源:origin: net.apexes.wsonrpc/wsonrpc-core

@Override
public JsonRpcRequest createRequest(String id, String method, Object[] params) {
  ObjectNode objectNode = objectMapper.getNodeFactory().objectNode();
  objectNode.put("jsonrpc", "2.0");
  if (id != null) {
    objectNode.put("id", id);
  }
  objectNode.put("method", method);
  if (params != null) {
    ArrayNode arrayNode = objectNode.putArray("params");
    for (Object param : params) {
      arrayNode.add(objectMapper.getNodeFactory().pojoNode(param));
    }
  }
  return new JacksonJsonRpcRequest(objectMapper, objectNode);
}

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

protected final JsonNode _fromEmbedded(JsonParser jp, DeserializationContext ctxt,
      JsonNodeFactory nodeFactory) throws IOException
  {
    // [JACKSON-796]
    Object ob = jp.getEmbeddedObject();
    if (ob == null) { // should this occur?
      return nodeFactory.nullNode();
    }
    Class<?> type = ob.getClass();
    if (type == byte[].class) { // most common special case
      return nodeFactory.binaryNode((byte[]) ob);
    }
    if (JsonNode.class.isAssignableFrom(type)) {
      // [Issue#433]: but could also be a JsonNode hiding in there!
      return (JsonNode) ob;
    }
    // any other special handling needed?
    return nodeFactory.pojoNode(ob);
  }
}

代码示例来源:origin: net.apexes.wsonrpc/wsonrpc-core

@Override
public JsonRpcResponse createResponse(String id, JsonRpcError error) {
  ObjectNode errorNode = objectMapper.getNodeFactory().objectNode();
  errorNode.put("code", error.getCode());
  if (error.getMessage() != null) {
    errorNode.put("message", error.getMessage());
  }
  if (error.getData() != null) {
    errorNode.set("data", objectMapper.getNodeFactory().pojoNode(error.getData()));
  }
  return createResponse(id, "error", errorNode);
}

代码示例来源:origin: infiniteautomation/ma-core-public

@Override
  public JsonNode getExplainInfo() {
    Map<String, Object> info = new HashMap<>();
    info.put("tags", new ParameterInfo("Map", true, null, new TranslatableMessage("common.default", "Tags used in query")));
    info.put("limit", new ParameterInfo("Number", false, null, new TranslatableMessage("common.default", "Limit of data points to return events for")));
    info.put("offset", new ParameterInfo("Number", false, 0, new TranslatableMessage("common.default", "Offset for limit")));
    return JsonNodeFactory.instance.pojoNode(info);
  }
}

相关文章