本文整理汇总了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);
}
}
示例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;
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例6: decorate
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public JsonGenerator decorate(JsonGenerator generator) {
if (prettyPrintingEnabled()) {
generator.useDefaultPrettyPrinter();
}
return generator;
}
示例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;
}
示例8: decorate
import com.fasterxml.jackson.core.JsonGenerator; //导入方法依赖的package包/类
@Override
public JsonGenerator decorate(JsonGenerator generator) {
return generator.useDefaultPrettyPrinter();
}
示例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;
}