Merge pull request #57 from square/jw/no-io

There is no I/O writing to a Buffer.
This commit is contained in:
Jesse Wilson
2015-06-17 10:11:38 -04:00

View File

@@ -44,9 +44,13 @@ public abstract class JsonAdapter<T> {
toJson(writer, value); toJson(writer, value);
} }
public final String toJson(T value) throws IOException { public final String toJson(T value) {
Buffer buffer = new Buffer(); Buffer buffer = new Buffer();
toJson(buffer, value); try {
toJson(buffer, value);
} catch (IOException e) {
throw new AssertionError(e); // No I/O writing to a Buffer.
}
return buffer.readUtf8(); return buffer.readUtf8();
} }