org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper.readValue()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(163)

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

ObjectMapper.readValue介绍

暂无

代码示例

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

/**
 * {@inheritDoc}
 */
@Override
public <C> C readObject(final InputStream inputStream, final Class<? extends C> clazz) throws IOException {
  return mapper.readValue(inputStream, clazz);
}

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

@Override
public ResponseMessage deserializeResponse(final String msg) throws SerializationException {
  try {
    return mapper.readValue(msg, ResponseMessage.class);
  } catch (Exception ex) {
    logger.warn("Response [{}] could not be deserialized by {}.", msg, AbstractGraphSONMessageSerializerV2d0.class.getName());
    throw new SerializationException(ex);
  }
}

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

@Override
public RequestMessage deserializeRequest(final String msg) throws SerializationException {
  try {
    return mapper.readValue(msg, RequestMessage.class);
  } catch (Exception ex) {
    logger.warn("Request [{}] could not be deserialized by {}.", msg, AbstractGraphSONMessageSerializerV2d0.class.getName());
    throw new SerializationException(ex);
  }
}

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

@Override
public RequestMessage deserializeRequest(final String msg) throws SerializationException {
  try {
    return mapper.readValue(msg, RequestMessage.class);
  } catch (Exception ex) {
    logger.warn(String.format("Request [%s] could not be deserialized by %s.", msg, GraphSONMessageSerializerV3d0.class.getName()), ex);
    throw new SerializationException(ex);
  }
}

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

@Override
public ResponseMessage deserializeResponse(final ByteBuf msg) throws SerializationException {
  try {
    final byte[] payload = new byte[msg.readableBytes()];
    msg.readBytes(payload);
    return mapper.readValue(payload, ResponseMessage.class);
  } catch (Exception ex) {
    logger.warn(String.format("Response [%s] could not be deserialized by %s.", msg, AbstractGraphSONMessageSerializerV2d0.class.getName()), ex);
    throw new SerializationException(ex);
  }
}

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

@Override
public RequestMessage deserializeRequest(final ByteBuf msg) throws SerializationException {
  try {
    final byte[] payload = new byte[msg.readableBytes()];
    msg.readBytes(payload);
    return mapper.readValue(payload, RequestMessage.class);
  } catch (Exception ex) {
    logger.warn(String.format("Request [%s] could not be deserialized by %s.", msg, AbstractGraphSONMessageSerializerV2d0.class.getName()), ex);
    throw new SerializationException(ex);
  }
}

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

@Override
public ResponseMessage deserializeResponse(final String msg) throws SerializationException {
  try {
    return mapper.readValue(msg, ResponseMessage.class);
  } catch (Exception ex) {
    logger.warn(String.format("Response [%s] could not be deserialized by %s.", msg, GraphSONMessageSerializerV3d0.class.getName()), ex);
    throw new SerializationException(ex);
  }
}

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

@Override
public RequestMessage deserializeRequest(final String msg) throws SerializationException {
  try {
    return mapper.readValue(msg, RequestMessage.class);
  } catch (Exception ex) {
    logger.warn("Request [{}] could not be deserialized by {}.", msg, AbstractGraphSONMessageSerializerV1d0.class.getName());
    throw new SerializationException(ex);
  }
}

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

@Override
public RequestMessage deserializeRequest(final ByteBuf msg) throws SerializationException {
  try {
    final byte[] payload = new byte[msg.readableBytes()];
    msg.readBytes(payload);
    return mapper.readValue(payload, RequestMessage.class);
  } catch (Exception ex) {
    logger.warn("Request [{}] could not be deserialized by {}.", msg, AbstractGraphSONMessageSerializerV1d0.class.getName());
    throw new SerializationException(ex);
  }
}

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

@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeEdge() throws Exception {
  final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V1_0)).mapper().version(GraphSONVersion.V1_0).create().createMapper();
  final Edge e = g.E(convertToEdgeId("marko", "knows", "vadas")).next();
  final String json = mapper.writeValueAsString(e);
  final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
  assertEquals(GraphSONTokens.EDGE, m.get(GraphSONTokens.TYPE));
  assertEquals(e.label(), m.get(GraphSONTokens.LABEL));
  assertNotNull(m.get(GraphSONTokens.ID));
  assertEquals((Double) e.value("weight"), ((Map) m.get(GraphSONTokens.PROPERTIES)).get("weight"));
}

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

@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexProperty() throws Exception {
  final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V1_0)).mapper().version(GraphSONVersion.V1_0).create().createMapper();
  final VertexProperty vp = graph.vertices(convertToVertexId("marko")).next().property("name");
  final String json = mapper.writeValueAsString(vp);
  final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
  assertEquals(vp.label(), m.get(GraphSONTokens.LABEL));
  assertNotNull(m.get(GraphSONTokens.ID));
  assertEquals(vp.value(), m.get(GraphSONTokens.VALUE));
}

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

@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeProperty() throws Exception {
  final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V1_0)).mapper().version(GraphSONVersion.V1_0).create().createMapper();
  final Property p = g.E(convertToEdgeId("marko", "knows", "vadas")).next().property("weight");
  final String json = mapper.writeValueAsString(p);
  final Map<String, Object> m = mapper.readValue(json, mapTypeReference);
  assertEquals(p.value(), m.get(GraphSONTokens.VALUE));
  assertEquals(p.key(), m.get(GraphSONTokens.KEY));
}

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

@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertex() throws Exception {
  final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V3_0)).mapper().version(GraphSONVersion.V3_0).create().createMapper();
  final Vertex v = graph.vertices(convertToVertexId("marko")).next();
  final String json = mapper.writeValueAsString(v);
  final Vertex detached = mapper.readValue(json, Vertex.class);
  assertNotNull(detached);
  assertEquals(v.label(), detached.label());
  assertEquals(v.id(), detached.id());
  assertEquals(v.value("name").toString(), detached.value("name"));
  assertEquals((Integer) v.value("age"), detached.value("age"));
}

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

@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertex() throws Exception {
  final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V2_0)).mapper().version(GraphSONVersion.V2_0).create().createMapper();
  final Vertex v = graph.vertices(convertToVertexId("marko")).next();
  final String json = mapper.writeValueAsString(v);
  final Vertex detached = mapper.readValue(json, Vertex.class);
  assertNotNull(detached);
  assertEquals(v.label(), detached.label());
  assertEquals(v.id(), detached.id());
  assertEquals(v.value("name").toString(), detached.value("name"));
  assertEquals((Integer) v.value("age"), detached.value("age"));
}

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

@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexProperty() throws Exception {
  final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V2_0)).mapper().version(GraphSONVersion.V2_0).create().createMapper();
  final VertexProperty vp = graph.vertices(convertToVertexId("marko")).next().property("name");
  final String json = mapper.writeValueAsString(vp);
  final VertexProperty detached = mapper.readValue(json, VertexProperty.class);
  assertNotNull(detached);
  assertEquals(vp.label(), detached.label());
  assertEquals(vp.id(), detached.id());
  assertEquals(vp.value(), detached.value());
}

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

@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexProperty() throws Exception {
  final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V3_0)).mapper().version(GraphSONVersion.V3_0).create().createMapper();
  final VertexProperty vp = graph.vertices(convertToVertexId("marko")).next().property("name");
  final String json = mapper.writeValueAsString(vp);
  final VertexProperty detached = mapper.readValue(json, VertexProperty.class);
  assertNotNull(detached);
  assertEquals(vp.label(), detached.label());
  assertEquals(vp.id(), detached.id());
  assertEquals(vp.value(), detached.value());
}

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

@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeProperty() throws Exception {
  final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V3_0)).mapper().version(GraphSONVersion.V3_0).create().createMapper();
  final Property p = g.E(convertToEdgeId("marko", "knows", "vadas")).next().property("weight");
  final String json = mapper.writeValueAsString(p);
  final Property detached = mapper.readValue(json, Property.class);
  assertNotNull(detached);
  assertEquals(p.key(), detached.key());
  assertEquals(p.value(), detached.value());
}

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

@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeProperty() throws Exception {
  final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V2_0)).mapper().version(GraphSONVersion.V2_0).create().createMapper();
  final Property p = g.E(convertToEdgeId("marko", "knows", "vadas")).next().property("weight");
  final String json = mapper.writeValueAsString(p);
  final Property detached = mapper.readValue(json, Property.class);
  assertNotNull(detached);
  assertEquals(p.key(), detached.key());
  assertEquals(p.value(), detached.value());
}

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

@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeEdge() throws Exception {
  final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V2_0)).mapper().version(GraphSONVersion.V2_0).create().createMapper();
  final Edge e = g.E(convertToEdgeId("marko", "knows", "vadas")).next();
  final String json = mapper.writeValueAsString(e);
  final Edge detached = mapper.readValue(json, Edge.class);
  assertNotNull(detached);
  assertEquals(e.label(), detached.label());
  assertEquals(e.id(), detached.id());
  assertEquals((Double) e.value("weight"), detached.value("weight"));
}

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

@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeEdge() throws Exception {
  final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V3_0)).mapper().version(GraphSONVersion.V3_0).create().createMapper();
  final Edge e = g.E(convertToEdgeId("marko", "knows", "vadas")).next();
  final String json = mapper.writeValueAsString(e);
  final Edge detached = mapper.readValue(json, Edge.class);
  assertNotNull(detached);
  assertEquals(e.label(), detached.label());
  assertEquals(e.id(), detached.id());
  assertEquals((Double) e.value("weight"), detached.value("weight"));
}

相关文章