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


Java JsonGenerator.useDefaultPrettyPrinter方法代码示例

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


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

示例1: toString

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public String toString(boolean pretty)
{
   try
   {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      JsonGenerator json = new JsonFactory().createGenerator(baos);
      if (pretty)
         json.useDefaultPrettyPrinter();
      write(json, new HashSet());
      json.flush();
      baos.flush();

      return new String(baos.toByteArray());
   }
   catch (Exception ex)
   {
      throw new RuntimeException(ex);
   }
}
 
开发者ID:wellsb1,项目名称:fort_w,代码行数:20,代码来源:JSObject.java

示例2: modify

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public ObjectWriter modify(EndpointConfigBase<?> endpointConfigBase, MultivaluedMap<String, Object> multivaluedMap,
                           Object o, ObjectWriter objectWriter, JsonGenerator jsonGenerator) throws IOException {

    jsonGenerator.useDefaultPrettyPrinter();
    return objectWriter;
}
 
开发者ID:stevespringett,项目名称:Alpine,代码行数:8,代码来源:PrettyPrintFilter.java

示例3: decorate

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public JsonGenerator decorate(JsonGenerator generator) {
  if (Boolean.valueOf(System.getenv("DENSE_LOGS"))) {
    return generator;
  }
  return generator.useDefaultPrettyPrinter();
}
 
开发者ID:codahale,项目名称:grpc-proxy,代码行数:8,代码来源:PrettyPrintingDecorator.java

示例4: writeInternal

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
protected void writeInternal(Object object, HttpOutputMessage outputMessage)
		throws IOException, HttpMessageNotWritableException {

	JsonEncoding encoding = getJsonEncoding(outputMessage.getHeaders().getContentType());
	// The following has been deprecated as late as Jackson 2.2 (April 2013);
	// preserved for the time being, for Jackson 2.0/2.1 compatibility.
	@SuppressWarnings("deprecation")
	JsonGenerator jsonGenerator =
			this.objectMapper.getJsonFactory().createJsonGenerator(outputMessage.getBody(), encoding);

	// A workaround for JsonGenerators not applying serialization features
	// https://github.com/FasterXML/jackson-databind/issues/12
	if (this.objectMapper.isEnabled(SerializationFeature.INDENT_OUTPUT)) {
		jsonGenerator.useDefaultPrettyPrinter();
	}

	try {
		if (this.jsonPrefix != null) {
			jsonGenerator.writeRaw(this.jsonPrefix);
		}
		this.objectMapper.writeValue(jsonGenerator, object);
	}
	catch (JsonProcessingException ex) {
		throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:MappingJackson2HttpMessageConverter.java

示例5: JsonWriter

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public JsonWriter(OutputStream out, boolean pretty, boolean useExtendedOutput) throws IOException{
  JsonGenerator writer = factory.createJsonGenerator(out);
  if(pretty){
    writer = writer.useDefaultPrettyPrinter();
  }
  if(useExtendedOutput){
    gen = new ExtendedJsonOutput(writer);
  }else{
    gen = new BasicJsonOutput(writer);
  }

}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:13,代码来源:JsonWriter.java

示例6: decorate

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public JsonGenerator decorate(JsonGenerator generator) {
    if (prettyPrintingEnabled()) {
        generator.useDefaultPrettyPrinter();
    }
    return generator;
}
 
开发者ID:hmcts,项目名称:java-logging,代码行数:8,代码来源:PrettyPrintingDecorator.java

示例7: modify

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public ObjectWriter modify(EndpointConfigBase<?> endpoint, MultivaluedMap<String, Object> responseHeaders,
    Object valueToWrite, ObjectWriter w, JsonGenerator g) throws IOException {
  ObjectWriter writer = w;
  if (previous != null) {
    writer = previous.modify(endpoint, responseHeaders, valueToWrite, w, g);
  }
  g.useDefaultPrettyPrinter();
  return writer;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:JSONPrettyPrintFilter.java

示例8: decorate

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public JsonGenerator decorate(JsonGenerator generator) {
    return generator.useDefaultPrettyPrinter();
}
 
开发者ID:skjolber,项目名称:json-log-domain,代码行数:5,代码来源:PrettyPrintingDecorator.java

示例9: createPrettyGenerator

import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
public static JsonGenerator createPrettyGenerator(Writer writer) throws IOException {
    JsonGenerator generator = prettyFactory.createGenerator(writer);
    generator.useDefaultPrettyPrinter();
    return generator;
}
 
开发者ID:line,项目名称:centraldogma,代码行数:6,代码来源:Jackson.java


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