use of org.hjson.Stringify in project cas by apereo.
the class AbstractJacksonBackedStringSerializer method to.
@Override
@SneakyThrows
public void to(final File out, final T object) {
try (StringWriter writer = new StringWriter()) {
this.objectMapper.writer(this.prettyPrinter).writeValue(writer, object);
if (isJsonFormat()) {
try (Writer fileWriter = Files.newBufferedWriter(out.toPath(), StandardCharsets.UTF_8)) {
final Stringify opt = this.prettyPrinter instanceof MinimalPrettyPrinter ? Stringify.PLAIN : Stringify.FORMATTED;
JsonValue.readHjson(writer.toString()).writeTo(fileWriter, opt);
fileWriter.flush();
}
} else {
FileUtils.write(out, writer.toString(), StandardCharsets.UTF_8);
}
}
}
use of org.hjson.Stringify in project cas by apereo.
the class AbstractJacksonBackedStringSerializer method to.
@Override
@SneakyThrows
public void to(final Writer out, final T object) {
try (StringWriter writer = new StringWriter()) {
this.objectMapper.writer(this.prettyPrinter).writeValue(writer, object);
if (isJsonFormat()) {
final Stringify opt = this.prettyPrinter instanceof MinimalPrettyPrinter ? Stringify.PLAIN : Stringify.FORMATTED;
JsonValue.readHjson(writer.toString()).writeTo(out, opt);
} else {
IOUtils.write(writer.toString(), out);
}
}
}
Aggregations