io.swagger.util.Yaml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swagger-all Show documentation
Show all versions of swagger-all Show documentation
swagger-all is a rebundled verison of Swagger as one OSGi bundle.
package io.swagger.util;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
public class Yaml {
static ObjectMapper mapper;
public static ObjectMapper mapper() {
if(mapper == null) {
mapper = ObjectMapperFactory.createYaml();
}
return mapper;
}
public static ObjectWriter pretty() {
return mapper().writer(new DefaultPrettyPrinter());
}
public static void prettyPrint(Object o) {
try {
System.out.println(pretty().writeValueAsString(o));
} catch (Exception e) {
e.printStackTrace();
}
}
}