### Question:
IrisObjectTypeAdapter extends TypeAdapter<Object> { @SuppressWarnings("unchecked") @Override public void write(JsonWriter out, Object value) throws IOException { if (value == null) { out.nullValue(); return; } TypeAdapter<Object> typeAdapter = (TypeAdapter<Object>) gson.getAdapter(value.getClass()); if (typeAdapter instanceof IrisObjectTypeAdapter) { out.beginObject(); out.endObject(); return; } typeAdapter.write(out, value); } IrisObjectTypeAdapter(Gson gson); @Override Object read(JsonReader in); @SuppressWarnings("unchecked") @Override void write(JsonWriter out, Object value);  }### Answer:
@Test public void testWrite() { assertEquals("null", gson.toJson(null, Object.class)); assertEquals("1", gson.toJson(1, Object.class)); assertEquals("1.0", gson.toJson(1.0, Object.class)); assertEquals("true", gson.toJson(true, Object.class)); assertEquals("\"string\"", gson.toJson("string", Object.class)); assertEquals("[]", gson.toJson(ImmutableSet.of(), Object.class)); assertEquals("{}", gson.toJson(ImmutableMap.of(), Object.class)); assertEquals("[1]", gson.toJson(ImmutableSet.of(1), Object.class)); assertEquals("{\"nested\":[\"string\"]}", gson.toJson(ImmutableMap.of("nested", ImmutableSet.of("string")), Object.class)); }