• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ObjectMapper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper类的具体用法?Java ObjectMapper怎么用?Java ObjectMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ObjectMapper类属于org.apache.tinkerpop.shaded.jackson.databind包,在下文中一共展示了ObjectMapper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: shouldSerializeTraversalMetrics

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Ignore
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeTraversalMetrics() throws Exception {
    final ObjectMapper mapper = graph.io(GraphSONIo.build()).mapper().create().createMapper();
    final TraversalMetrics tm = (TraversalMetrics) g.V().both().profile().next();
    final String json = mapper.writeValueAsString(tm);
    final Map<String, Object> m = mapper.readValue(json, mapTypeReference);

    assertTrue(m.containsKey(GraphSONTokens.DURATION));
    assertTrue(m.containsKey(GraphSONTokens.METRICS));

    final List<Map<String, Object>> metrics = (List<Map<String, Object>>) m.get(GraphSONTokens.METRICS);
    assertEquals(2, metrics.size());

    final Map<String, Object> metrics0 = metrics.get(0);
    assertTrue(metrics0.containsKey(GraphSONTokens.ID));
    assertTrue(metrics0.containsKey(GraphSONTokens.NAME));
    assertTrue(metrics0.containsKey(GraphSONTokens.COUNTS));
    assertTrue(metrics0.containsKey(GraphSONTokens.DURATION));
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:22,代码来源:CustomTest.java


示例2: shouldSerializeVertex

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertex() throws Exception {
    final ObjectMapper mapper = graph.io(GraphSONIo.build()).mapper().create().createMapper();
    final Vertex v = graph.vertices(convertToVertexId("marko")).next();
    final String json = mapper.writeValueAsString(v);
    final Map<String, Object> m = mapper.readValue(json, mapTypeReference);

    assertEquals(GraphSONTokens.VERTEX, m.get(GraphSONTokens.TYPE));
    assertEquals(v.label(), m.get(GraphSONTokens.LABEL));
    assertNotNull(m.get(GraphSONTokens.ID));
    final Map<String,List<Map<String,Object>>> properties = (Map<String,List<Map<String,Object>>>) m.get(GraphSONTokens.PROPERTIES);
    assertEquals(v.value("name").toString(), properties.get("name").get(0).get(GraphSONTokens.VALUE).toString());
    assertEquals((Integer) v.value("age"), properties.get("age").get(0).get(GraphSONTokens.VALUE));
    assertEquals(1, properties.get("name").size());
    assertEquals(1, properties.get("age").size());
    assertEquals(2, properties.size());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:19,代码来源:SerializationTest.java


示例3: shouldSerializeTraversalMetrics

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeTraversalMetrics() throws Exception {
    final ObjectMapper mapper = graph.io(GraphSONIo.build()).mapper().create().createMapper();
    final TraversalMetrics tm = (TraversalMetrics) g.V().both().profile().next();
    final String json = mapper.writeValueAsString(tm);
    final Map<String, Object> m = mapper.readValue(json, mapTypeReference);

    assertTrue(m.containsKey(GraphSONTokens.DURATION));
    assertTrue(m.containsKey(GraphSONTokens.METRICS));

    final List<Map<String, Object>> metrics = (List<Map<String, Object>>) m.get(GraphSONTokens.METRICS);
    assertEquals(2, metrics.size());

    final Map<String, Object> metrics0 = metrics.get(0);
    assertTrue(metrics0.containsKey(GraphSONTokens.ID));
    assertTrue(metrics0.containsKey(GraphSONTokens.NAME));
    assertTrue(metrics0.containsKey(GraphSONTokens.COUNTS));
    assertTrue(metrics0.containsKey(GraphSONTokens.DURATION));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:SerializationTest.java


示例4: testGeoJsonCircle

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
public void testGeoJsonCircle() throws IOException {
    Geoshape.GeoshapeSerializer s = new Geoshape.GeoshapeSerializer();
    Map json = new ObjectMapper().readValue("{\n" +
            "  \"type\": \"Feature\",\n" +
            "  \"geometry\": {\n" +
            "    \"type\": \"Circle\",\n" +
            "    \"radius\": 30.5, " +
            "    \"coordinates\": [20.5, 10.5]\n" +
            "  },\n" +
            "  \"properties\": {\n" +
            "    \"name\": \"Dinagat Islands\"\n" +
            "  }\n" +
            "}", HashMap.class);
    assertEquals(Geoshape.circle(10.5, 20.5, 30.5), s.convert(json));
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:17,代码来源:GeoshapeTest.java


示例5: testGeoJsonPolygonNotBox1

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testGeoJsonPolygonNotBox1() throws IOException {
    Geoshape.GeoshapeSerializer s = new Geoshape.GeoshapeSerializer();
    Map json = new ObjectMapper().readValue("{\n" +
            "  \"type\": \"Feature\",\n" +
            "  \"geometry\": {\n" +
            "    \"type\": \"Polygon\",\n" +
            "    \"coordinates\": [[20.5, 12.5],[22.5, 12.5],[22.5, 10.5],[20.5, 10.6]]\n" +
            "  },\n" +
            "  \"properties\": {\n" +
            "    \"name\": \"Dinagat Islands\"\n" +
            "  }\n" +
            "}", HashMap.class);
    s.convert(json);

}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:17,代码来源:GeoshapeTest.java


示例6: testGeoJsonPolygonNotBox2

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testGeoJsonPolygonNotBox2() throws IOException {
    Geoshape.GeoshapeSerializer s = new Geoshape.GeoshapeSerializer();
    Map json = new ObjectMapper().readValue("{\n" +
            "  \"type\": \"Feature\",\n" +
            "  \"geometry\": {\n" +
            "    \"type\": \"Polygon\",\n" +
            "    \"coordinates\": [[20.5, 10.5],[22.5, 10.5],[22.5, 12.5]]\n" +
            "  },\n" +
            "  \"properties\": {\n" +
            "    \"name\": \"Dinagat Islands\"\n" +
            "  }\n" +
            "}", HashMap.class);
     s.convert(json);

}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:17,代码来源:GeoshapeTest.java


示例7: shouldSerializeAndDeserializeRequestMessageFromObjectMapper

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
public void shouldSerializeAndDeserializeRequestMessageFromObjectMapper() throws IOException {
    final ObjectMapper om = GraphSONMapper.build().version(GraphSONVersion.V2_0)
            .addCustomModule(new GraphSONMessageSerializerGremlinV2d0.GremlinServerModule())
            .create().createMapper();

    final Map<String, Object> requestBindings = new HashMap<>();
    requestBindings.put("x", 1);

    final Map<String, Object> requestAliases = new HashMap<>();
    requestAliases.put("g", "social");

    final RequestMessage requestMessage = RequestMessage.build("eval").processor("session").
            overrideRequestId(UUID.fromString("cb682578-9d92-4499-9ebc-5c6aa73c5397")).
            add("gremlin", "social.V(x)", "bindings", requestBindings, "language", "gremlin-groovy", "aliases", requestAliases, "session", UUID.fromString("41d2e28a-20a4-4ab0-b379-d810dede3786")).create();

    final String json = om.writeValueAsString(requestMessage);
    final RequestMessage readRequestMessage = om.readValue(json, RequestMessage.class);

    assertEquals(requestMessage.getOp(), readRequestMessage.getOp());
    assertEquals(requestMessage.getProcessor(), readRequestMessage.getProcessor());
    assertEquals(requestMessage.getRequestId(), readRequestMessage.getRequestId());
    assertEquals(requestMessage.getArgs(), readRequestMessage.getArgs());
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:25,代码来源:GraphSONMessageSerializerV2d0Test.java


示例8: shouldSerializeAndDeserializeResponseMessageFromObjectMapper

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
public void shouldSerializeAndDeserializeResponseMessageFromObjectMapper() throws IOException {
    final ObjectMapper om = GraphSONMapper.build().version(GraphSONVersion.V2_0)
            .addCustomModule(new GraphSONMessageSerializerGremlinV2d0.GremlinServerModule())
            .create().createMapper();
    final Graph graph = TinkerFactory.createModern();

    final ResponseMessage responseMessage = ResponseMessage.build(UUID.fromString("41d2e28a-20a4-4ab0-b379-d810dede3786")).
            code(org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode.SUCCESS).
            result(Collections.singletonList(graph.vertices().next())).create();

    final String respJson = om.writeValueAsString(responseMessage);
    final ResponseMessage responseMessageRead = om.readValue(respJson, ResponseMessage.class);

    assertEquals(responseMessage.getRequestId(), responseMessageRead.getRequestId());
    assertEquals(responseMessage.getResult().getMeta(), responseMessageRead.getResult().getMeta());
    assertEquals(responseMessage.getResult().getData(), responseMessageRead.getResult().getData());
    assertEquals(responseMessage.getStatus().getAttributes(), responseMessageRead.getStatus().getAttributes());
    assertEquals(responseMessage.getStatus().getCode().getValue(), responseMessageRead.getStatus().getCode().getValue());
    assertEquals(responseMessage.getStatus().getCode().isSuccess(), responseMessageRead.getStatus().getCode().isSuccess());
    assertEquals(responseMessage.getStatus().getMessage(), responseMessageRead.getStatus().getMessage());
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:23,代码来源:GraphSONMessageSerializerV2d0Test.java


示例9: shouldHandleMapWithTypesUsingEmbedTypeSettingV2d0

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
public void shouldHandleMapWithTypesUsingEmbedTypeSettingV2d0() throws Exception {
    final ObjectMapper mapper = GraphSONMapper.build()
            .version(GraphSONVersion.V2_0)
            .typeInfo(TypeInfo.PARTIAL_TYPES)
            .create()
            .createMapper();

    final Map<String,Object> m = new HashMap<>();
    m.put("test", 100L);

    final String json = mapper.writeValueAsString(m);
    final Map read = mapper.readValue(json, HashMap.class);

    assertEquals(100L, read.get("test"));
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:17,代码来源:GraphSONMapperPartialEmbeddedTypeTest.java


示例10: shouldNotHandleMapWithTypesUsingEmbedTypeSettingV2d0

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
public void shouldNotHandleMapWithTypesUsingEmbedTypeSettingV2d0() throws Exception {
    final ObjectMapper mapper = GraphSONMapper.build()
            .version(GraphSONVersion.V2_0)
            .typeInfo(TypeInfo.NO_TYPES)
            .create()
            .createMapper();

    final Map<String,Object> m = new HashMap<>();
    m.put("test", 100L);

    final String json = mapper.writeValueAsString(m);
    final Map read = mapper.readValue(json, HashMap.class);

    assertEquals(100, read.get("test"));
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:17,代码来源:GraphSONMapperPartialEmbeddedTypeTest.java


示例11: shouldHandleMapWithTypesUsingEmbedTypeSettingV1d0

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
public void shouldHandleMapWithTypesUsingEmbedTypeSettingV1d0() throws Exception {
    final ObjectMapper mapper = GraphSONMapper.build()
            .version(GraphSONVersion.V1_0)
            .typeInfo(TypeInfo.PARTIAL_TYPES)
            .create()
            .createMapper();

    final Map<String,Object> m = new HashMap<>();
    m.put("test", 100L);

    final String json = mapper.writeValueAsString(m);
    final Map read = mapper.readValue(json, HashMap.class);

    assertEquals(100L, read.get("test"));
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:17,代码来源:GraphSONMapperPartialEmbeddedTypeTest.java


示例12: shouldNotHandleMapWithTypesUsingEmbedTypeSettingV1d0

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
public void shouldNotHandleMapWithTypesUsingEmbedTypeSettingV1d0() throws Exception {
    final ObjectMapper mapper = GraphSONMapper.build()
            .version(GraphSONVersion.V1_0)
            .typeInfo(TypeInfo.NO_TYPES)
            .create()
            .createMapper();

    final Map<String,Object> m = new HashMap<>();
    m.put("test", 100L);

    final String json = mapper.writeValueAsString(m);
    final Map read = mapper.readValue(json, HashMap.class);

    assertEquals(100, read.get("test"));
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:17,代码来源:GraphSONMapperPartialEmbeddedTypeTest.java


示例13: shouldSerializeVertex

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertex() throws Exception {
    final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V1_0)).mapper().version(GraphSONVersion.V1_0).create().createMapper();
    final Vertex v = graph.vertices(convertToVertexId("marko")).next();
    final String json = mapper.writeValueAsString(v);
    final Map<String, Object> m = mapper.readValue(json, mapTypeReference);

    assertEquals(GraphSONTokens.VERTEX, m.get(GraphSONTokens.TYPE));
    assertEquals(v.label(), m.get(GraphSONTokens.LABEL));
    assertNotNull(m.get(GraphSONTokens.ID));
    final Map<String,List<Map<String,Object>>> properties = (Map<String,List<Map<String,Object>>>) m.get(GraphSONTokens.PROPERTIES);
    assertEquals(v.value("name").toString(), properties.get("name").get(0).get(GraphSONTokens.VALUE).toString());
    assertEquals((Integer) v.value("age"), properties.get("age").get(0).get(GraphSONTokens.VALUE));
    assertEquals(1, properties.get("name").size());
    assertEquals(1, properties.get("age").size());
    assertEquals(2, properties.size());
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:19,代码来源:SerializationTest.java


示例14: shouldSerializeTraversalMetrics

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeTraversalMetrics() throws Exception {
    final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V1_0)).mapper().version(GraphSONVersion.V1_0).create().createMapper();
    final TraversalMetrics tm = g.V().both().profile().next();
    final String json = mapper.writeValueAsString(tm);
    final Map<String, Object> m = mapper.readValue(json, mapTypeReference);

    assertTrue(m.containsKey(GraphSONTokens.DURATION));
    assertTrue(m.containsKey(GraphSONTokens.METRICS));

    final List<Map<String, Object>> metrics = (List<Map<String, Object>>) m.get(GraphSONTokens.METRICS);
    assertEquals(tm.getMetrics().size(), metrics.size());

    final Map<String, Object> metrics0 = metrics.get(0);
    assertTrue(metrics0.containsKey(GraphSONTokens.ID));
    assertTrue(metrics0.containsKey(GraphSONTokens.NAME));
    assertTrue(metrics0.containsKey(GraphSONTokens.COUNTS));
    assertTrue(metrics0.containsKey(GraphSONTokens.DURATION));
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:21,代码来源:SerializationTest.java


示例15: shouldSerializeVertexPropertyWithProperties

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.CREW)
public void shouldSerializeVertexPropertyWithProperties() throws Exception {
    final ObjectMapper mapper = graph.io(GraphSONIo.build(GraphSONVersion.V2_0)).mapper().version(GraphSONVersion.V2_0).create().createMapper();
    final VertexProperty vp = IteratorUtils.filter(graph.vertices(convertToVertexId("marko")).next().properties("location"), p -> p.value().equals("brussels")).next();
    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());
    assertEquals(vp.values("startTime").next(), detached.values("startTime").next());
    assertEquals(((Property) vp.properties("startTime").next()).key(), ((Property) detached.properties("startTime").next()).key());
    assertEquals(vp.values("endTime").next(), detached.values("endTime").next());
    assertEquals(((Property) vp.properties("endTime").next()).key(), ((Property) detached.properties("endTime").next()).key());
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:18,代码来源:SerializationTest.java


示例16: shouldDeserializeNumbers

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
public void shouldDeserializeNumbers() throws Exception {
    for (final GraphSONVersion version : VERSIONS) {
        final ScriptEngine jythonEngine = JythonScriptEngineSetup.setup((PyScriptEngine) new ScriptEngineManager().getEngineByName("jython"));
        jythonEngine.eval("graphson_reader = " + (version.equals(GraphSONVersion.V2_0) ? "graphsonV2d0_reader" : "graphsonV3d0_reader"));
        final ObjectMapper mapper = GraphSONMapper.build().version(version).create().createMapper();
        //
        jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", mapper.writeValueAsString(1));
        assertEquals("1", jythonEngine.eval("str(graphson_reader.readObject(x))"));
        assertTrue((Boolean) jythonEngine.eval("isinstance(graphson_reader.readObject(x),int)"));
        //
        jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", mapper.writeValueAsString(1L));
        assertEquals("1", jythonEngine.eval("str(graphson_reader.readObject(x))"));
        assertTrue((Boolean) jythonEngine.eval("isinstance(graphson_reader.readObject(x),long)"));
        //
        jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", mapper.writeValueAsString(1.2f));
        assertEquals("1.2", jythonEngine.eval("str(graphson_reader.readObject(x))"));
        assertTrue((Boolean) jythonEngine.eval("isinstance(graphson_reader.readObject(x),float)"));
        //
        jythonEngine.getBindings(ScriptContext.ENGINE_SCOPE).put("x", mapper.writeValueAsString(1.3d));
        assertEquals("1.3", jythonEngine.eval("str(graphson_reader.readObject(x))"));
        assertTrue((Boolean) jythonEngine.eval("isinstance(graphson_reader.readObject(x),float)"));
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:25,代码来源:GraphSONReaderTest.java


示例17: shouldSerializeNumbers

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
public void shouldSerializeNumbers() throws Exception {
    for (final GraphSONVersion version : VERSIONS) {
        final ScriptEngine jythonEngine = JythonScriptEngineSetup.setup((PyScriptEngine) new ScriptEngineManager().getEngineByName("jython"));
        jythonEngine.eval("graphson_writer = " + (version.equals(GraphSONVersion.V2_0) ? "graphsonV2d0_writer" : "graphsonV3d0_writer"));
        final ObjectMapper mapper = GraphSONMapper.build().version(version).create().createMapper();
        //
        assertEquals(1, mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(1)").toString(), Object.class));
        assertEquals(mapper.writeValueAsString(1), jythonEngine.eval("graphson_writer.writeObject(1)").toString().replace(" ", ""));
        //
        assertEquals(2L, mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(2L)").toString(), Object.class));
        assertEquals(mapper.writeValueAsString(2L), jythonEngine.eval("graphson_writer.writeObject(2L)").toString().replace(" ", ""));
        //
        assertEquals(3.4, mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(3.4)").toString(), Object.class));
        assertEquals(mapper.writeValueAsString(3.4), jythonEngine.eval("graphson_writer.writeObject(3.4)").toString().replace(" ", ""));
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:18,代码来源:GraphSONWriterTest.java


示例18: shouldSerializeCollections

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
public void shouldSerializeCollections() throws Exception {
    for (final GraphSONVersion version : VERSIONS) {
        final ScriptEngine jythonEngine = JythonScriptEngineSetup.setup((PyScriptEngine) new ScriptEngineManager().getEngineByName("jython"));
        jythonEngine.eval("graphson_writer = " + (version.equals(GraphSONVersion.V2_0) ? "graphsonV2d0_writer" : "graphsonV3d0_writer"));
        final ObjectMapper mapper = GraphSONMapper.build().version(version).create().createMapper();
        //
        final Map<String, Number> map = new LinkedHashMap<>();
        map.put("a", 2);
        map.put("b", 2.3);
        assertEquals(map, mapper.readValue(jythonEngine.eval("graphson_writer.writeObject({'a':2,'b':2.3})").toString(), Object.class));
        //
        final List<Object> list = Arrays.asList(new DefaultRemoteTraverser<>("hello", 3L), "hello", map, true);
        assertTrue((Boolean) jythonEngine.eval("isinstance([Traverser('hello',3L),'hello',{'a':2,'b':2.3},True],list)"));
        assertEquals(list, mapper.readValue(jythonEngine.eval("graphson_writer.writeObject([Traverser('hello',3L),'hello',{'a':2,'b':2.3},True])").toString(), Object.class));
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:18,代码来源:GraphSONWriterTest.java


示例19: shouldSerializeLambda

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
public void shouldSerializeLambda() throws Exception {
    for (final GraphSONVersion version : VERSIONS) {
        final ScriptEngine jythonEngine = JythonScriptEngineSetup.setup((PyScriptEngine) new ScriptEngineManager().getEngineByName("jython"));
        jythonEngine.eval("graphson_writer = " + (version.equals(GraphSONVersion.V2_0) ? "graphsonV2d0_writer" : "graphsonV3d0_writer"));
        final ObjectMapper mapper = GraphSONMapper.build().version(version).create().createMapper();
        //
        assertEquals(
                Lambda.function("lambda z : 1+2", "gremlin-python"),
                mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(lambda : 'z : 1+2')").toString(), Object.class));
        assertEquals(
                Lambda.function("lambda z : z+ 7", "gremlin-python"),
                mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(lambda : 'lambda z : z+ 7')").toString(), Object.class));
        assertEquals(
                Lambda.supplier("lambda : 23", "gremlin-python"),
                mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(lambda : 'lambda : 23')").toString(), Object.class));
        assertEquals(
                Lambda.consumer("lambda z : z + 23", "gremlin-python"),
                mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(lambda : 'lambda z : z + 23')").toString(), Object.class));
        assertEquals(
                Lambda.biFunction("lambda z,y : z - y + 2", "gremlin-python"),
                mapper.readValue(jythonEngine.eval("graphson_writer.writeObject(lambda : 'lambda z,y : z - y + 2')").toString(), Object.class));
    }
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:25,代码来源:GraphSONWriterTest.java


示例20: shouldSerializeTinkerGraphToGraphSONWithTypes

import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper; //导入依赖的package包/类
@Test
public void shouldSerializeTinkerGraphToGraphSONWithTypes() throws Exception {
    final TinkerGraph graph = TinkerFactory.createModern();
    final Mapper<ObjectMapper> mapper = graph.io(IoCore.graphson()).mapper().typeInfo(TypeInfo.PARTIAL_TYPES).create();
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        final GraphWriter writer = GraphSONWriter.build().mapper(mapper).create();
        writer.writeObject(out, graph);
        try (final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray())) {
            final GraphReader reader = GraphSONReader.build().mapper(mapper).create();
            final TinkerGraph target = reader.readObject(inputStream, TinkerGraph.class);
            IoTest.assertModernGraph(target, true, false);
        }
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:15,代码来源:TinkerGraphTest.java



注:本文中的org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java KafkaUtils类代码示例发布时间:2022-05-22
下一篇:
Java POSTNETBean类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap