diff --git a/gson/src/main/java/com/google/gson/Gson.java b/gson/src/main/java/com/google/gson/Gson.java index a06f290747..2ee5920b85 100644 --- a/gson/src/main/java/com/google/gson/Gson.java +++ b/gson/src/main/java/com/google/gson/Gson.java @@ -47,14 +47,16 @@ import java.util.concurrent.ConcurrentMap; /** - * This is the main class for using Gson. Gson is typically used by first constructing a Gson - * instance and then invoking {@link #toJson(Object)} or {@link #fromJson(String, Class)} methods on - * it. Gson instances are Thread-safe so you can reuse them freely across multiple threads. + * This is the main class for using Gson. Gson is typically used by first constructing a {@code + * Gson} instance and then invoking {@link #toJson(Object)} or {@link #fromJson(String, Class)} + * methods on it. {@code Gson} instances are Thread-safe so you can reuse them freely across + * multiple threads. * - *
You can create a Gson instance by invoking {@code new Gson()} if the default configuration is - * all you need. You can also use {@link GsonBuilder} to build a Gson instance with various - * configuration options such as versioning support, pretty printing, custom newline, custom indent, - * custom {@link JsonSerializer}s, {@link JsonDeserializer}s, and {@link InstanceCreator}s. + *
You can create a {@code Gson} instance by invoking {@link #Gson() new Gson()} if the default + * configuration is all you need. You can also use {@link GsonBuilder} to build a {@code Gson} + * instance with various configuration options such as versioning support, pretty printing, custom + * newline, custom indent, custom {@link JsonSerializer}s, {@link JsonDeserializer}s, and {@link + * InstanceCreator}s. * *
Here is an example of how Gson is used for a simple Class: * @@ -89,6 +91,11 @@ *
See the Gson User Guide * for a more complete set of examples. * + *
When serializing or deserializing a type, {@code Gson} instances cache the type adapters they + * created for that type. It can therefore improve performance to reuse a single {@code Gson} + * instance (for example by storing it in a {@code static final} field), especially when relying on + * the built-in reflection-based adapter or when using custom type adapter factories. + * *