当前位置: 首页>>代码示例>>Java>>正文


Java ObjectMapper.addMixInAnnotations方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.ObjectMapper.addMixInAnnotations方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper.addMixInAnnotations方法的具体用法?Java ObjectMapper.addMixInAnnotations怎么用?Java ObjectMapper.addMixInAnnotations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.ObjectMapper的用法示例。


在下文中一共展示了ObjectMapper.addMixInAnnotations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSerialize

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Test
public void testSerialize() throws Exception {
    String expected = "{\"version\":null,\"status\":0,\"routeInstructions\":null,\"routeGeometry\":[[50.753,5.712],[50.653,6.012]]}";
    GeoCoordinates[] coords = new GeoCoordinates[2];
    coords[0] = new GeoCoordinates(50.753, 5.712);
    coords[1] = new GeoCoordinates(50.653, 6.012);
    PathData pathData = new PathData.Builder().withRouteGeometry(coords).build();

    ObjectMapper mapper = new ObjectMapper();
    mapper.addMixInAnnotations(PathData.class, UraPathDataMixIn.class);
    Writer stringWriter = new StringWriter();
    try {
        mapper.writeValue(stringWriter, pathData);
        String json = stringWriter.toString();
        assertNotNull(json);
        assertEquals(json, expected);
    } catch (Exception e) {
        fail();
    }
}
 
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:21,代码来源:UraSerializerWrapperTest.java

示例2: testModalTypeSerialization

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Test
public void testModalTypeSerialization() {
    String expected = "{\"type\":\"IndividualTrip\",\"uuid\":null,\"start\":null,\"end\":null,\"status\":null," +
            "\"lengthInM\":0.0,\"messageList\":null,\"modalType\":\"walk\",\"isAccessible\":null," +
            "\"ticketMatches\":null,\"pathDataSource\":null,\"pathData\":null,\"durationInS\":null}";
    IndividualTrip trip = new IndividualTrip.Builder().withModalType(ModalType.walk).build();
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JodaModule());
    mapper.addMixInAnnotations(IndividualTrip.class, UraIndividualTripMixIn.class);
    Writer stringWriter = new StringWriter();
    try {
        mapper.writeValue(stringWriter, trip);
        String json = stringWriter.toString();
        assertNotNull(json);
        assertEquals(json, expected);
    } catch (Exception e) {
        fail();
    }
}
 
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:20,代码来源:UraModalTypeWrapperTest.java


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