use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project topcom-cloud by 545314690.
the class MyWebAppConfigurer method extendMessageConverters.
/**
* 添加返回结果缩进支持,如果存在pretty参数,则返回结果添加缩进
* @param converters
*/
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.replaceAll(c -> {
if (c instanceof MappingJackson2HttpMessageConverter) {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(mapper) {
@Override
protected void writePrefix(JsonGenerator generator, Object object) throws IOException {
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
if (attributes != null && attributes instanceof ServletRequestAttributes) {
String attribute = ((ServletRequestAttributes) attributes).getRequest().getParameter("pretty");
if (attribute != null) {
generator.setPrettyPrinter(new DefaultPrettyPrinter());
}
}
super.writePrefix(generator, object);
}
};
return converter;
} else {
return c;
}
});
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project topcom-cloud by 545314690.
the class MyWebAppConfigurer method extendMessageConverters.
/**
* 添加返回结果缩进支持,如果存在pretty参数,则返回结果添加缩进
* @param converters
*/
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.replaceAll(c -> {
if (c instanceof MappingJackson2HttpMessageConverter) {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(mapper) {
@Override
protected void writePrefix(JsonGenerator generator, Object object) throws IOException {
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
if (attributes != null && attributes instanceof ServletRequestAttributes) {
String attribute = ((ServletRequestAttributes) attributes).getRequest().getParameter("pretty");
if (attribute != null) {
generator.setPrettyPrinter(new DefaultPrettyPrinter());
}
}
super.writePrefix(generator, object);
}
};
return converter;
} else {
return c;
}
});
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project spring-framework by spring-projects.
the class AbstractJackson2HttpMessageConverter method init.
protected void init(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
setDefaultCharset(DEFAULT_CHARSET);
DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
prettyPrinter.indentObjectsWith(new DefaultIndenter(" ", "\ndata:"));
this.ssePrettyPrinter = prettyPrinter;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project geode by apache.
the class PdxToJSON method enableDisableJSONGeneratorFeature.
private void enableDisableJSONGeneratorFeature(JsonGenerator jg) {
jg.enable(Feature.ESCAPE_NON_ASCII);
jg.disable(Feature.AUTO_CLOSE_TARGET);
jg.setPrettyPrinter(new DefaultPrettyPrinter());
if (PDXTOJJSON_UNQUOTEFIELDNAMES)
jg.disable(Feature.QUOTE_FIELD_NAMES);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project midpoint by Evolveum.
the class JsonLexicalProcessor method createJsonGenerator.
private JsonGenerator createJsonGenerator(StringWriter out) throws SchemaException {
try {
JsonFactory factory = new JsonFactory();
JsonGenerator generator = factory.createGenerator(out);
generator.setPrettyPrinter(new DefaultPrettyPrinter());
generator.setCodec(configureMapperForSerialization());
return generator;
} catch (IOException ex) {
throw new SchemaException("Schema error during serializing to JSON.", ex);
}
}
Aggregations