當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。