com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(100)

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

ObjectMapper._configAndWriteValue介绍

[英]Method called to configure the generator as necessary and then call write functionality
[中]方法以根据需要配置生成器,然后调用写入功能

代码示例

代码示例来源:origin: redisson/redisson

/**
 * Method that can be used to serialize any Java value as
 * JSON output, written to File provided.
 */
public void writeValue(File resultFile, Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{
  _configAndWriteValue(_jsonFactory.createGenerator(resultFile, JsonEncoding.UTF8), value);
}

代码示例来源:origin: redisson/redisson

/**
 * @since 2.8
 */
public void writeValue(DataOutput out, Object value)
  throws IOException
{
  _configAndWriteValue(_jsonFactory.createGenerator(out, JsonEncoding.UTF8), value);
}

代码示例来源:origin: redisson/redisson

/**
 * Method that can be used to serialize any Java value as
 * JSON output, using Writer provided.
 *<p>
 * Note: method does not close the underlying stream explicitly
 * here; however, {@link JsonFactory} this mapper uses may choose
 * to close the stream depending on its settings (by default,
 * it will try to close it when {@link JsonGenerator} we construct
 * is closed).
 */
public void writeValue(Writer w, Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{
  _configAndWriteValue(_jsonFactory.createGenerator(w), value);
}

代码示例来源:origin: redisson/redisson

/**
 * Method that can be used to serialize any Java value as
 * JSON output, using output stream provided (using encoding
 * {@link JsonEncoding#UTF8}).
 *<p>
 * Note: method does not close the underlying stream explicitly
 * here; however, {@link JsonFactory} this mapper uses may choose
 * to close the stream depending on its settings (by default,
 * it will try to close it when {@link JsonGenerator} we construct
 * is closed).
 */
public void writeValue(OutputStream out, Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{
  _configAndWriteValue(_jsonFactory.createGenerator(out, JsonEncoding.UTF8), value);
}

代码示例来源:origin: redisson/redisson

/**
 * Method that can be used to serialize any Java value as
 * a String. Functionally equivalent to calling
 * {@link #writeValue(Writer,Object)} with {@link java.io.StringWriter}
 * and constructing String, but more efficient.
 *<p>
 * Note: prior to version 2.1, throws clause included {@link IOException}; 2.1 removed it.
 */
@SuppressWarnings("resource")
public String writeValueAsString(Object value)
  throws JsonProcessingException
{
  // alas, we have to pull the recycler directly here...
  SegmentedStringWriter sw = new SegmentedStringWriter(_jsonFactory._getBufferRecycler());
  try {
    _configAndWriteValue(_jsonFactory.createGenerator(sw), value);
  } catch (JsonProcessingException e) {
    throw e;
  } catch (IOException e) { // shouldn't really happen, but is declared as possibility so:
    throw JsonMappingException.fromUnexpectedIOE(e);
  }
  return sw.getAndClear();
}

代码示例来源:origin: redisson/redisson

/**
 * Method that can be used to serialize any Java value as
 * a byte array. Functionally equivalent to calling
 * {@link #writeValue(Writer,Object)} with {@link java.io.ByteArrayOutputStream}
 * and getting bytes, but more efficient.
 * Encoding used will be UTF-8.
 *<p>
 * Note: prior to version 2.1, throws clause included {@link IOException}; 2.1 removed it.
 */
@SuppressWarnings("resource")
public byte[] writeValueAsBytes(Object value)
  throws JsonProcessingException
{
  ByteArrayBuilder bb = new ByteArrayBuilder(_jsonFactory._getBufferRecycler());
  try {
    _configAndWriteValue(_jsonFactory.createGenerator(bb, JsonEncoding.UTF8), value);
  } catch (JsonProcessingException e) { // to support [JACKSON-758]
    throw e;
  } catch (IOException e) { // shouldn't really happen, but is declared as possibility so:
    throw JsonMappingException.fromUnexpectedIOE(e);
  }
  byte[] result = bb.toByteArray();
  bb.release();
  return result;
}

代码示例来源:origin: com.jwebmp.jackson.core/jackson-databind

/**
 * Method that can be used to serialize any Java value as
 * JSON output, written to File provided.
 */
public void writeValue(File resultFile, Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{
  _configAndWriteValue(_jsonFactory.createGenerator(resultFile, JsonEncoding.UTF8), value);
}

代码示例来源:origin: com.jwebmp.jackson.core/jackson-databind

/**
 * @since 2.8
 */
public void writeValue(DataOutput out, Object value)
  throws IOException
{
  _configAndWriteValue(_jsonFactory.createGenerator(out, JsonEncoding.UTF8), value);
}

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

/**
 * Method that can be used to serialize any Java value as
 * JSON output, written to File provided.
 */
public void writeValue(File resultFile, Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{
  _configAndWriteValue(_jsonFactory.createGenerator(resultFile, JsonEncoding.UTF8), value);
}

代码示例来源:origin: Nextdoor/bender

/**
 * @since 2.8
 */
public void writeValue(DataOutput out, Object value)
  throws IOException
{
  _configAndWriteValue(_jsonFactory.createGenerator(out, JsonEncoding.UTF8), value);
}

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

/**
 * Method that can be used to serialize any Java value as
 * JSON output, written to File provided.
 */
public void writeValue(File resultFile, Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{
  _configAndWriteValue(_jsonFactory.createGenerator(resultFile, JsonEncoding.UTF8), value);
}

代码示例来源:origin: Nextdoor/bender

/**
 * Method that can be used to serialize any Java value as
 * JSON output, written to File provided.
 */
public void writeValue(File resultFile, Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{
  _configAndWriteValue(_jsonFactory.createGenerator(resultFile, JsonEncoding.UTF8), value);
}

代码示例来源:origin: com.jwebmp.jackson.core/jackson-databind

/**
 * Method that can be used to serialize any Java value as
 * JSON output, using Writer provided.
 *<p>
 * Note: method does not close the underlying stream explicitly
 * here; however, {@link JsonFactory} this mapper uses may choose
 * to close the stream depending on its settings (by default,
 * it will try to close it when {@link JsonGenerator} we construct
 * is closed).
 */
public void writeValue(Writer w, Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{
  _configAndWriteValue(_jsonFactory.createGenerator(w), value);
}

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

/**
 * Method that can be used to serialize any Java value as
 * JSON output, using Writer provided.
 *<p>
 * Note: method does not close the underlying stream explicitly
 * here; however, {@link JsonFactory} this mapper uses may choose
 * to close the stream depending on its settings (by default,
 * it will try to close it when {@link JsonGenerator} we construct
 * is closed).
 */
public void writeValue(Writer w, Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{
  _configAndWriteValue(_jsonFactory.createGenerator(w), value);
}

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

/**
 * Method that can be used to serialize any Java value as
 * JSON output, using Writer provided.
 *<p>
 * Note: method does not close the underlying stream explicitly
 * here; however, {@link JsonFactory} this mapper uses may choose
 * to close the stream depending on its settings (by default,
 * it will try to close it when {@link JsonGenerator} we construct
 * is closed).
 */
public void writeValue(Writer w, Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{
  _configAndWriteValue(_jsonFactory.createGenerator(w), value);
}

代码示例来源:origin: Nextdoor/bender

/**
 * Method that can be used to serialize any Java value as
 * JSON output, using Writer provided.
 *<p>
 * Note: method does not close the underlying stream explicitly
 * here; however, {@link JsonFactory} this mapper uses may choose
 * to close the stream depending on its settings (by default,
 * it will try to close it when {@link JsonGenerator} we construct
 * is closed).
 */
public void writeValue(Writer w, Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{
  _configAndWriteValue(_jsonFactory.createGenerator(w), value);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Method that can be used to serialize any Java value as
 * JSON output, written to File provided.
 */
public void writeValue(File resultFile, Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{
  _configAndWriteValue(_jsonFactory.createJsonGenerator(resultFile, JsonEncoding.UTF8), value);
}

代码示例来源:origin: com.fasterxml.jackson.core/com.springsource.com.fasterxml.jackson.core.jackson-databind

/**
 * Method that can be used to serialize any Java value as
 * JSON output, written to File provided.
 */
public void writeValue(File resultFile, Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{
  _configAndWriteValue(_jsonFactory.createJsonGenerator(resultFile, JsonEncoding.UTF8), value);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Method that can be used to serialize any Java value as
 * JSON output, using Writer provided.
 *<p>
 * Note: method does not close the underlying stream explicitly
 * here; however, {@link JsonFactory} this mapper uses may choose
 * to close the stream depending on its settings (by default,
 * it will try to close it when {@link JsonGenerator} we construct
 * is closed).
 */
public void writeValue(Writer w, Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{
  _configAndWriteValue(_jsonFactory.createJsonGenerator(w), value);
}

代码示例来源:origin: com.fasterxml.jackson.core/com.springsource.com.fasterxml.jackson.core.jackson-databind

/**
 * Method that can be used to serialize any Java value as
 * a String. Functionally equivalent to calling
 * {@link #writeValue(Writer,Object)} with {@link java.io.StringWriter}
 * and constructing String, but more efficient.
 */
public String writeValueAsString(Object value)
  throws IOException, JsonGenerationException, JsonMappingException
{        
  // alas, we have to pull the recycler directly here...
  SegmentedStringWriter sw = new SegmentedStringWriter(_jsonFactory._getBufferRecycler());
  _configAndWriteValue(_jsonFactory.createJsonGenerator(sw), value);
  return sw.getAndClear();
}

相关文章

微信公众号

最新文章

更多

ObjectMapper类方法