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


Java ObjectMapper.writer方法代码示例

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


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

示例1: getText

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Override
public String getText(JsonNode jsonNode, int prettyIndent) throws ServiceException {
    
    ObjectMapper mapper = new ObjectMapper();
    try {
        ObjectWriter writer;
        if (prettyIndent > 0)
            writer = mapper.writer(new JacksonPrettyPrinter(prettyIndent));
        else
            writer = mapper.writer();
        
        return writer.writeValueAsString(jsonNode);
    }
    catch (JsonProcessingException ex) {
        throw new ServiceException(Status.INTERNAL_ERROR, ex.getMessage(), ex);
    }
}
 
开发者ID:limberest,项目名称:limberest,代码行数:18,代码来源:JsonNodeService.java

示例2: getWriter

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
protected ObjectWriter getWriter(Format format, int prettyIndent) {
    ObjectMapper mapper = getMapper(format);
    if (prettyIndent > 0)
        return mapper.writer(new JacksonPrettyPrinter(prettyIndent));
    else
        return mapper.writer();        
}
 
开发者ID:limberest,项目名称:limberest,代码行数:8,代码来源:ServiceApi.java

示例3: SnsListener

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
SnsListener(AmazonSNSAsyncClient sns, ListenerConfig config, Clock clock) {
  this.clock = clock;
  LOG.info("Starting listener, topics: start={}, success={}, fail={}", config.getStartTopic(),
      config.getSuccessTopic(), config.getFailTopic());
  this.sns = sns;
  this.config = config;
  ObjectMapper mapper = new ObjectMapper();
  mapper.setSerializationInclusion(Include.NON_NULL);
  startWriter = mapper.writer();
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:11,代码来源:SnsListener.java

示例4: testMapper

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Test
public void testMapper() throws Exception {

    final ObjectMapper objectMapper = objectMapperProvider.getContext(null);
    final Blah value = new Blah();
    value.setHello("abc");
    final ObjectWriter writer = objectMapper.writer();
    final String str = writer.writeValueAsString(value);
    final Blah value2 = objectMapper.readerFor(Blah.class).readValue(str);
    assertEquals(value.getHello(), value2.getHello());
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:12,代码来源:ObjectMapperTest.java

示例5: JacksonSerializer

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public JacksonSerializer(ObjectMapper mapper, Class<X> clazz){
  this.reader = mapper.reader(clazz);
  this.writer = mapper.writer();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:5,代码来源:JacksonSerializer.java

示例6: Json

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private Json(ObjectMapper mapper) {
    this.mapper = mapper;
    this.writer = mapper.writer();
    this.prettyWriter = mapper.writerWithDefaultPrettyPrinter();
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:6,代码来源:Json.java

示例7: JacksonSerializer

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public JacksonSerializer(final ObjectMapper mapper, final Class<T> klazz) {
  this.reader = mapper.readerFor(klazz);
  this.writer = mapper.writer();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:JacksonSerializer.java

示例8: createObjectWriter

import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private static ObjectWriter createObjectWriter(ObjectMapper objectMapper, boolean prettyPrintEnabled) {
    ObjectWriter objectWriter = prettyPrintEnabled
            ? objectMapper.writerWithDefaultPrettyPrinter()
            : objectMapper.writer();
    return objectWriter.withoutFeatures(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
}
 
开发者ID:vy,项目名称:log4j2-logstash-layout,代码行数:7,代码来源:TemplateRenderer.java


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