1 package org
.asamk
.signal
;
3 import com
.fasterxml
.jackson
.core
.JsonProcessingException
;
4 import com
.fasterxml
.jackson
.databind
.ObjectMapper
;
6 import org
.asamk
.signal
.util
.Util
;
8 import java
.io
.IOException
;
11 public class JsonWriterImpl
implements JsonWriter
{
13 private final Writer writer
;
14 private final ObjectMapper objectMapper
;
16 public JsonWriterImpl(final Writer writer
) {
18 this.objectMapper
= Util
.createJsonObjectMapper();
21 public synchronized void write(final Object object
) {
24 objectMapper
.writeValue(writer
, object
);
25 } catch (JsonProcessingException e
) {
26 // Some issue with json serialization, probably caused by a bug
27 throw new AssertionError(e
);
29 writer
.write(System
.lineSeparator());
31 } catch (IOException e
) {
32 throw new AssertionError(e
);