use of com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project elasticsearch by elastic.
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 midpoint by Evolveum.
the class YamlLexicalProcessor method createJacksonGenerator.
public YAMLGenerator createJacksonGenerator(StringWriter out) throws SchemaException {
try {
MidpointYAMLFactory factory = new MidpointYAMLFactory();
MidpointYAMLGenerator generator = (MidpointYAMLGenerator) 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);
}
}
use of com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project jackson-core by FasterXML.
the class TestJDKSerializability method testPrettyPrinter.
public void testPrettyPrinter() throws Exception {
PrettyPrinter p = new DefaultPrettyPrinter();
byte[] stuff = jdkSerialize(p);
PrettyPrinter back = jdkDeserialize(stuff);
// what should we test?
assertNotNull(back);
}
use of com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project geode by apache.
the class JSONUtils method enableDisableJSONGeneratorFeature.
public static JsonGenerator enableDisableJSONGeneratorFeature(JsonGenerator generator) {
generator.enable(Feature.ESCAPE_NON_ASCII);
generator.disable(Feature.AUTO_CLOSE_TARGET);
generator.setPrettyPrinter(new DefaultPrettyPrinter());
return generator;
}
use of com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project tutorials by eugenp.
the class JacksonSerializeUnitTest method whenCustomSerialize_thenCorrect.
@Test
public void whenCustomSerialize_thenCorrect() throws ParseException, IOException {
final SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
final ActorJackson rudyYoungblood = new ActorJackson("nm2199632", sdf.parse("21-09-1982"), Arrays.asList("Apocalypto", "Beatdown", "Wind Walkers"));
final MovieWithNullValue movieWithNullValue = new MovieWithNullValue(null, "Mel Gibson", Arrays.asList(rudyYoungblood));
final SimpleModule module = new SimpleModule();
module.addSerializer(new ActorJacksonSerializer(ActorJackson.class));
final ObjectMapper mapper = new ObjectMapper();
final String jsonResult = mapper.registerModule(module).writer(new DefaultPrettyPrinter()).writeValueAsString(movieWithNullValue);
final Object json = mapper.readValue("{\"actors\":[{\"imdbId\":\"nm2199632\",\"dateOfBirth\":\"21-09-1982\",\"N° Film: \":3,\"filmography\":\"Apocalypto-Beatdown-Wind Walkers\"}],\"imdbID\":null}", Object.class);
final String expectedOutput = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(json);
Assert.assertEquals(jsonResult, expectedOutput);
}
Aggregations