use of org.immutables.gson.stream.GsonMessageBodyProvider.GsonOptions in project immutables by immutables.
the class JaxrsTest method propagateGsonAttributes.
@Test
public void propagateGsonAttributes() {
Gson gson = new GsonBuilder().serializeNulls().disableHtmlEscaping().setPrettyPrinting().create();
GsonOptions options = new GsonOptions(gson, true);
JsonReader reader = new JsonReader(new StringReader(""));
options.setReaderOptions(reader);
check(reader.isLenient());
JsonWriter writer = new JsonWriter(new StringWriter());
options.setWriterOptions(writer);
check(writer.isLenient());
check(!writer.isHtmlSafe());
check(writer.getSerializeNulls());
// checks pretty printing
check(gson.toJson(Collections.singletonMap("k", "v"))).is("{\n \"k\": \"v\"\n}");
}
Aggregations