use of com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project azure-tools-for-java by Microsoft.
the class CustomerSurveyManager method saveSurveyStatus.
private void saveSurveyStatus() {
final ObjectMapper mapper = new ObjectMapper();
final ObjectWriter writer = mapper.writer(new DefaultPrettyPrinter());
final File file = getConfigurationFile();
try {
if (!file.exists()) {
file.createNewFile();
}
writer.writeValue(file, customerSurveyConfiguration);
} catch (final IOException e) {
// swallow exceptions for survey
}
}
use of com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project qpp-conversion-tool by CMSgov.
the class JsonWrapper method getPrinter.
private static DefaultPrettyPrinter getPrinter() {
DefaultIndenter withLinefeed = new DefaultIndenter(" ", "\n");
DefaultPrettyPrinter printer = new DefaultPrettyPrinter();
printer.indentObjectsWith(withLinefeed);
return printer;
}
use of com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project zipkin by openzipkin.
the class JsonUtil method createGenerator.
/**
* Creates a new {@link JsonGenerator} with pretty-printing enabled forcing {@code '\n'}
* between lines, as opposed to Jackson's default which uses the system line separator.
*/
public static JsonGenerator createGenerator(Writer writer) throws IOException {
JsonGenerator generator = JSON_FACTORY.createGenerator(writer);
DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
prettyPrinter.indentArraysWith(TWOSPACES_LF_INDENTER);
prettyPrinter.indentObjectsWith(TWOSPACES_LF_INDENTER);
generator.setPrettyPrinter(prettyPrinter);
return generator;
}
use of com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project crate by crate.
the class JsonXContentGenerator method usePrettyPrint.
@Override
public final void usePrettyPrint() {
generator.setPrettyPrinter(new DefaultPrettyPrinter().withObjectIndenter(INDENTER).withArrayIndenter(INDENTER));
prettyPrint = true;
}
use of com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project swagger-core by swagger-api.
the class BaseOpenApiResource method getOpenApi.
protected Response getOpenApi(HttpHeaders headers, ServletConfig config, Application app, UriInfo uriInfo, String type) throws Exception {
String ctxId = getContextId(config);
OpenApiContext ctx = new JaxrsOpenApiContextBuilder().servletConfig(config).application(app).resourcePackages(resourcePackages).configLocation(configLocation).openApiConfiguration(openApiConfiguration).ctxId(ctxId).buildContext(true);
OpenAPI oas = ctx.read();
boolean pretty = false;
if (ctx.getOpenApiConfiguration() != null && Boolean.TRUE.equals(ctx.getOpenApiConfiguration().isPrettyPrint())) {
pretty = true;
}
if (oas != null) {
if (ctx.getOpenApiConfiguration() != null && ctx.getOpenApiConfiguration().getFilterClass() != null) {
try {
OpenAPISpecFilter filterImpl = (OpenAPISpecFilter) Class.forName(ctx.getOpenApiConfiguration().getFilterClass()).newInstance();
SpecFilter f = new SpecFilter();
oas = f.filter(oas, filterImpl, getQueryParams(uriInfo.getQueryParameters()), getCookies(headers), getHeaders(headers));
} catch (Exception e) {
LOGGER.error("failed to load filter", e);
}
}
}
if (oas == null) {
return Response.status(404).build();
}
if (StringUtils.isNotBlank(type) && type.trim().equalsIgnoreCase("yaml")) {
return Response.status(Response.Status.OK).entity(pretty ? ctx.getOutputYamlMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(oas) : ctx.getOutputYamlMapper().writeValueAsString(oas)).type("application/yaml").build();
} else {
return Response.status(Response.Status.OK).entity(pretty ? ctx.getOutputJsonMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(oas) : ctx.getOutputJsonMapper().writeValueAsString(oas)).type(MediaType.APPLICATION_JSON_TYPE).build();
}
}
Aggregations