Expose newJsonWriter wrapper instead of just options.

This is more future proof to ensure that consumers holding on to TypeAdapters for efficiency can always encode JSON in the same way as if the Gson instance was used directly.
This commit is contained in:
Jake Wharton 2015-09-26 19:19:38 -04:00
parent 31f80d8659
commit e81f3eba27

View File

@ -247,11 +247,6 @@ public final class Gson {
this.factories = Collections.unmodifiableList(factories); this.factories = Collections.unmodifiableList(factories);
} }
/** Returns true if this Gson instance writes fields with null values. */
public boolean serializeNulls() {
return serializeNulls;
}
private TypeAdapter<Number> doubleAdapter(boolean serializeSpecialFloatingPointValues) { private TypeAdapter<Number> doubleAdapter(boolean serializeSpecialFloatingPointValues) {
if (serializeSpecialFloatingPointValues) { if (serializeSpecialFloatingPointValues) {
return TypeAdapters.DOUBLE; return TypeAdapters.DOUBLE;
@ -648,10 +643,9 @@ public final class Gson {
} }
/** /**
* Returns a new JSON writer configured for this GSON and with the non-execute * Returns a new JSON writer configured for the settings on this Gson instance.
* prefix if that is configured.
*/ */
private JsonWriter newJsonWriter(Writer writer) throws IOException { public JsonWriter newJsonWriter(Writer writer) throws IOException {
if (generateNonExecutableJson) { if (generateNonExecutableJson) {
writer.write(JSON_NON_EXECUTABLE_PREFIX); writer.write(JSON_NON_EXECUTABLE_PREFIX);
} }