diff --git a/gson/docs/javadocs/allclasses-frame.html b/gson/docs/javadocs/allclasses-frame.html new file mode 100644 index 00000000..30bf2b5b --- /dev/null +++ b/gson/docs/javadocs/allclasses-frame.html @@ -0,0 +1,92 @@ + + + +
+ + +ExclusionStrategy
+ +Expose + +FieldAttributes + +FieldNamingPolicy + +FieldNamingStrategy + +Gson + +GsonBuilder + +InstanceCreator + +JsonArray + +JsonDeserializationContext + +JsonDeserializer + +JsonElement + +JsonIOException + +JsonNull + +JsonObject + +JsonParseException + +JsonParser + +JsonPrimitive + +JsonReader + +JsonSerializationContext + +JsonSerializer + +JsonStreamParser + +JsonSyntaxException + +JsonToken + +JsonWriter + +LongSerializationPolicy + +MalformedJsonException + +SerializedName + +Since + +TypeToken + +Until + + |
+
ExclusionStrategy
+ +Expose + +FieldAttributes + +FieldNamingPolicy + +FieldNamingStrategy + +Gson + +GsonBuilder + +InstanceCreator + +JsonArray + +JsonDeserializationContext + +JsonDeserializer + +JsonElement + +JsonIOException + +JsonNull + +JsonObject + +JsonParseException + +JsonParser + +JsonPrimitive + +JsonReader + +JsonSerializationContext + +JsonSerializer + +JsonStreamParser + +JsonSyntaxException + +JsonToken + +JsonWriter + +LongSerializationPolicy + +MalformedJsonException + +SerializedName + +Since + +TypeToken + +Until + + |
+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
public interface ExclusionStrategy
+A strategy (or policy) definition that is used to decide whether or not a field or top-level
+ class should be serialized or deserialized as part of the JSON output/input. For serialization,
+ if the shouldSkipClass(Class)
method returns false then that class or field type
+ will not be part of the JSON output. For deserialization, if shouldSkipClass(Class)
+ returns false, then it will not be set as part of the Java object structure.
+
+
The following are a few examples that shows how you can use this exclusion mechanism. + +
Exclude fields and objects based on a particular class type: +
+ private static class SpecificClassExclusionStrategy implements ExclusionStrategy { + private final Class<?> excludedThisClass; + + public SpecificClassExclusionStrategy(Class<?> excludedThisClass) { + this.excludedThisClass = excludedThisClass; + } + + public boolean shouldSkipClass(Class<?> clazz) { + return excludedThisClass.equals(clazz); + } + + public boolean shouldSkipField(FieldAttributes f) { + return excludedThisClass.equals(f.getDeclaredClass()); + } + } ++ +
Excludes fields and objects based on a particular annotation: +
+ public @interface FooAnnotation { + // some implementation here + } + + // Excludes any field (or class) that is tagged with an "@FooAnnotation" + private static class FooAnnotationExclusionStrategy implements ExclusionStrategy { + public boolean shouldSkipClass(Class<?> clazz) { + return clazz.getAnnotation(FooAnnotation.class) != null; + } + + public boolean shouldSkipField(FieldAttributes f) { + return f.getAnnotation(FooAnnotation.class) != null; + } + } ++ +
Now if you want to configure Gson
to use a user defined exclusion strategy, then
+ the GsonBuilder
is required. The following is an example of how you can use the
+ GsonBuilder
to configure Gson to use one of the above sample:
+
+ ExclusionStrategy excludeStrings = new UserDefinedExclusionStrategy(String.class); + Gson gson = new GsonBuilder() + .setExclusionStrategies(excludeStrings) + .create(); ++ +
For certain model classes, you may only want to serialize a field, but exclude it for
+ deserialization. To do that, you can write an ExclusionStrategy
as per normal;
+ however, you would register it with the
+ GsonBuilder.addDeserializationExclusionStrategy(ExclusionStrategy)
method.
+ For example:
+
+ ExclusionStrategy excludeStrings = new UserDefinedExclusionStrategy(String.class); + Gson gson = new GsonBuilder() + .addDeserializationExclusionStrategy(excludeStrings) + .create(); ++
+ +
+
GsonBuilder.setExclusionStrategies(ExclusionStrategy...)
,
+GsonBuilder.addDeserializationExclusionStrategy(ExclusionStrategy)
,
+GsonBuilder.addSerializationExclusionStrategy(ExclusionStrategy)
+Method Summary | +|
---|---|
+ boolean |
+shouldSkipClass(Class<?> clazz)
+
++ |
+
+ boolean |
+shouldSkipField(FieldAttributes f)
+
++ |
+
+Method Detail | +
---|
+boolean shouldSkipField(FieldAttributes f)+
f
- the field object that is under test
++boolean shouldSkipClass(Class<?> clazz)+
clazz
- the class object that is under test
+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.FieldAttributes ++
public final class FieldAttributes
+A data object that stores attributes of a field. + +
This class is immutable; therefore, it can be safely shared across threads. +
+ +
+
+Method Summary | +||
---|---|---|
+
+ |
+getAnnotation(Class<T> annotation)
+
++ Return the T annotation object from this field if it exist; otherwise returns
+ null . |
+|
+ Collection<Annotation> |
+getAnnotations()
+
++ Return the annotations that are present on this field. |
+|
+ Class<?> |
+getDeclaredClass()
+
++ Returns the Class object that was declared for this field. |
+|
+ Type |
+getDeclaredType()
+
++ For example, assume the following class definition: + + public class Foo { + private String bar; + private List<String> red; + } + + Type listParmeterizedType = new TypeToken<List<String>>() {}.getType(); |
+|
+ Class<?> |
+getDeclaringClass()
+
++ |
+|
+ String |
+getName()
+
++ |
+|
+ boolean |
+hasModifier(int modifier)
+
++ Returns true if the field is defined with the modifier . |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Method Detail | +
---|
+public Class<?> getDeclaringClass()+
+public String getName()+
+public Type getDeclaredType()+
For example, assume the following class definition: +
+ public class Foo { + private String bar; + private List<String> red; + } + + Type listParmeterizedType = new TypeToken<List<String>>() {}.getType(); ++ +
This method would return String.class
for the bar
field and
+ listParameterizedType
for the red
field.
+
+
+public Class<?> getDeclaredClass()+
Class
object that was declared for this field.
+
+ For example, assume the following class definition: +
+ public class Foo { + private String bar; + private List<String> red; + } ++ +
This method would return String.class
for the bar
field and
+ List.class
for the red
field.
+
+
+public <T extends Annotation> T getAnnotation(Class<T> annotation)+
T
annotation object from this field if it exist; otherwise returns
+ null
.
++
annotation
- the class of the annotation that will be retrieved
+null
+public Collection<Annotation> getAnnotations()+
+
+public boolean hasModifier(int modifier)+
true
if the field is defined with the modifier
.
+
+ This method is meant to be called as: +
+ boolean hasPublicModifier = fieldAttribute.hasModifier(java.lang.reflect.Modifier.PUBLIC); ++
+
Modifier
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | ++DETAIL: ENUM CONSTANTS | FIELD | METHOD | +
+java.lang.Object + java.lang.Enum<FieldNamingPolicy> + com.google.gson.FieldNamingPolicy ++
public enum FieldNamingPolicy
+An enumeration that defines a few standard naming conventions for JSON field names.
+ This enumeration should be used in conjunction with GsonBuilder
+ to configure a Gson
instance to properly translate Java field
+ names into the desired JSON field names.
+
+ +
+
+Enum Constant Summary | +|
---|---|
LOWER_CASE_WITH_DASHES
+
++ Using this naming policy with Gson will modify the Java Field name from its camel cased + form to a lower case field name where each word is separated by a dash (-). |
+|
LOWER_CASE_WITH_UNDERSCORES
+
++ Using this naming policy with Gson will modify the Java Field name from its camel cased + form to a lower case field name where each word is separated by an underscore (_). |
+|
UPPER_CAMEL_CASE
+
++ Using this naming policy with Gson will ensure that the first "letter" of the Java + field name is capitalized when serialized to its JSON form. |
+|
UPPER_CAMEL_CASE_WITH_SPACES
+
++ Using this naming policy with Gson will ensure that the first "letter" of the Java + field name is capitalized when serialized to its JSON form and the words will be + separated by a space. |
+
+Method Summary | +|
---|---|
+static FieldNamingPolicy |
+valueOf(String name)
+
++ Returns the enum constant of this type with the specified name. |
+
+static FieldNamingPolicy[] |
+values()
+
++ Returns an array containing the constants of this enum type, in +the order they are declared. |
+
Methods inherited from class java.lang.Enum | +
---|
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
+
Methods inherited from class java.lang.Object | +
---|
getClass, notify, notifyAll, wait, wait, wait |
+
+Enum Constant Detail | +
---|
+public static final FieldNamingPolicy UPPER_CAMEL_CASE+
Here's a few examples of the form "Java Field Name" ---> "JSON Field Name":
++
+public static final FieldNamingPolicy UPPER_CAMEL_CASE_WITH_SPACES+
Here's a few examples of the form "Java Field Name" ---> "JSON Field Name":
++
+public static final FieldNamingPolicy LOWER_CASE_WITH_UNDERSCORES+
Here's a few examples of the form "Java Field Name" ---> "JSON Field Name":
++
+public static final FieldNamingPolicy LOWER_CASE_WITH_DASHES+
Here's a few examples of the form "Java Field Name" ---> "JSON Field Name":
+myobject['my-field']
. Accessing it as an object field
+ myobject.my-field
will result in an unintended javascript expression.
++
+Method Detail | +
---|
+public static FieldNamingPolicy[] values()+
+for (FieldNamingPolicy c : FieldNamingPolicy.values()) + System.out.println(c); ++
+
+public static FieldNamingPolicy valueOf(String name)+
+
name
- the name of the enum constant to be returned.
+IllegalArgumentException
- if this enum type has no constant
+with the specified name
+NullPointerException
- if the argument is null
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | ++DETAIL: ENUM CONSTANTS | FIELD | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
public interface FieldNamingStrategy
+A mechanism for providing custom field naming in Gson. This allows the client code to translate + field names into a particular convention that is not supported as a normal Java field + declaration rules. For example, Java does not support "-" characters in a field name. +
+ +
+
+Method Summary | +|
---|---|
+ String |
+translateName(Field f)
+
++ Translates the field name into its JSON field name representation. |
+
+Method Detail | +
---|
+String translateName(Field f)+
+
f
- the field object that we are translating
+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.Gson ++
public final class Gson
+This is the main class for using Gson. Gson is typically used by first constructing a
+ Gson instance and then invoking toJson(Object)
or fromJson(String, Class)
+ methods on it.
+
+
You can create a Gson instance by invoking new Gson()
if the default configuration
+ is all you need. You can also use GsonBuilder
to build a Gson instance with various
+ configuration options such as versioning support, pretty printing, custom
+ JsonSerializer
s, JsonDeserializer
s, and InstanceCreator
s.
Here is an example of how Gson is used for a simple Class: + +
+ Gson gson = new Gson(); // Or use new GsonBuilder().create(); + MyType target = new MyType(); + String json = gson.toJson(target); // serializes target to Json + MyType target2 = gson.fromJson(json, MyType.class); // deserializes json into target2 ++ +
If the object that your are serializing/deserializing is a ParameterizedType
+ (i.e. contains at least one type parameter and may be an array) then you must use the
+ toJson(Object, Type)
or fromJson(String, Type)
method. Here is an
+ example for serializing and deserialing a ParameterizedType
:
+
+
+ Type listType = new TypeToken<List<String>>() {}.getType(); + List<String> target = new LinkedList<String>(); + target.add("blah"); + + Gson gson = new Gson(); + String json = gson.toJson(target, listType); + List<String> target2 = gson.fromJson(json, listType); ++ +
See the Gson User Guide + for a more complete set of examples.
++ +
+
TypeToken
+Constructor Summary | +|
---|---|
Gson()
+
++ Constructs a Gson object with default configuration. |
+
+Method Summary | +||
---|---|---|
+
+ |
+fromJson(JsonElement json,
+ Class<T> classOfT)
+
++ This method deserializes the Json read from the specified parse tree into an object of the + specified type. |
+|
+
+ |
+fromJson(JsonElement json,
+ Type typeOfT)
+
++ This method deserializes the Json read from the specified parse tree into an object of the + specified type. |
+|
+
+ |
+fromJson(JsonReader reader,
+ Type typeOfT)
+
++ Reads the next JSON value from reader and convert it to an object
+ of type typeOfT . |
+|
+
+ |
+fromJson(Reader json,
+ Class<T> classOfT)
+
++ This method deserializes the Json read from the specified reader into an object of the + specified class. |
+|
+
+ |
+fromJson(Reader json,
+ Type typeOfT)
+
++ This method deserializes the Json read from the specified reader into an object of the + specified type. |
+|
+
+ |
+fromJson(String json,
+ Class<T> classOfT)
+
++ This method deserializes the specified Json into an object of the specified class. |
+|
+
+ |
+fromJson(String json,
+ Type typeOfT)
+
++ This method deserializes the specified Json into an object of the specified type. |
+|
+ String |
+toJson(JsonElement jsonElement)
+
++ Converts a tree of JsonElement s into its equivalent JSON representation. |
+|
+ void |
+toJson(JsonElement jsonElement,
+ Appendable writer)
+
++ Writes out the equivalent JSON for a tree of JsonElement s. |
+|
+ void |
+toJson(JsonElement jsonElement,
+ JsonWriter writer)
+
++ Writes the JSON for jsonElement to writer . |
+|
+ String |
+toJson(Object src)
+
++ This method serializes the specified object into its equivalent Json representation. |
+|
+ void |
+toJson(Object src,
+ Appendable writer)
+
++ This method serializes the specified object into its equivalent Json representation. |
+|
+ String |
+toJson(Object src,
+ Type typeOfSrc)
+
++ This method serializes the specified object, including those of generic types, into its + equivalent Json representation. |
+|
+ void |
+toJson(Object src,
+ Type typeOfSrc,
+ Appendable writer)
+
++ This method serializes the specified object, including those of generic types, into its + equivalent Json representation. |
+|
+ void |
+toJson(Object src,
+ Type typeOfSrc,
+ JsonWriter writer)
+
++ Writes the JSON representation of src of type typeOfSrc to
+ writer . |
+|
+ JsonElement |
+toJsonTree(Object src)
+
++ This method serializes the specified object into its equivalent representation as a tree of + JsonElement s. |
+|
+ JsonElement |
+toJsonTree(Object src,
+ Type typeOfSrc)
+
++ This method serializes the specified object, including those of generic types, into its + equivalent representation as a tree of JsonElement s. |
+|
+ String |
+toString()
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public Gson()+
toJson
methods is in compact representation. This
+ means that all the unneeded white-space is removed. You can change this behavior with
+ GsonBuilder.setPrettyPrinting()
. GsonBuilder.serializeNulls()
.Map
,
+ URL
, URI
, Locale
, Date
,
+ BigDecimal
, and BigInteger
classes. If you would prefer
+ to change the default representation, you can do so by registering a type adapter through
+ GsonBuilder.registerTypeAdapter(Type, Object)
. DateFormat.DEFAULT
. This format
+ ignores the millisecond portion of the date during serialization. You can change
+ this by invoking GsonBuilder.setDateFormat(int)
or
+ GsonBuilder.setDateFormat(String)
. Expose
annotation.
+ You can enable Gson to serialize/deserialize only those fields marked with this annotation
+ through GsonBuilder.excludeFieldsWithoutExposeAnnotation()
. Since
annotation. You
+ can enable Gson to use this annotation through GsonBuilder.setVersion(double)
.versionNumber
will be output as "versionNumber@quot;
in
+ Json. The same rules are applied for mapping incoming Json to the Java classes. You can
+ change this policy through GsonBuilder.setFieldNamingPolicy(FieldNamingPolicy)
.transient
or static
fields from
+ consideration for serialization and deserialization. You can change this behavior through
+ GsonBuilder.excludeFieldsWithModifiers(int...)
.+
+Method Detail | +
---|
+public JsonElement toJsonTree(Object src)+
JsonElement
s. This method should be used when the specified object is not a generic
+ type. This method uses Object.getClass()
to get the type for the specified object, but
+ the getClass()
loses the generic type information because of the Type Erasure feature
+ of Java. Note that this method works fine if the any of the object fields are of generic type,
+ just the object itself should not be of a generic type. If the object is of generic type, use
+ toJsonTree(Object, Type)
instead.
++
src
- the object for which Json representation is to be created setting for Gson
+src
.+public JsonElement toJsonTree(Object src, + Type typeOfSrc)+
JsonElement
s. This method must be used if the
+ specified object is a generic type. For non-generic objects, use toJsonTree(Object)
+ instead.
++
src
- the object for which JSON representation is to be createdtypeOfSrc
- The specific genericized type of src. You can obtain
+ this type by using the TypeToken
class. For example,
+ to get the type for Collection<Foo>
, you should use:
+ + Type typeOfSrc = new TypeToken<Collection<Foo>>(){}.getType(); ++
src
+public String toJson(Object src)+
Object.getClass()
to get the type for the specified object, but the
+ getClass()
loses the generic type information because of the Type Erasure feature
+ of Java. Note that this method works fine if the any of the object fields are of generic type,
+ just the object itself should not be of a generic type. If the object is of generic type, use
+ toJson(Object, Type)
instead. If you want to write out the object to a
+ Writer
, use toJson(Object, Appendable)
instead.
++
src
- the object for which Json representation is to be created setting for Gson
+src
.+public String toJson(Object src, + Type typeOfSrc)+
toJson(Object)
instead. If you want to write out
+ the object to a Appendable
, use toJson(Object, Type, Appendable)
instead.
++
src
- the object for which JSON representation is to be createdtypeOfSrc
- The specific genericized type of src. You can obtain
+ this type by using the TypeToken
class. For example,
+ to get the type for Collection<Foo>
, you should use:
+ + Type typeOfSrc = new TypeToken<Collection<Foo>>(){}.getType(); ++
src
+public void toJson(Object src, + Appendable writer) + throws JsonIOException+
Object.getClass()
to get the type for the specified object, but the
+ getClass()
loses the generic type information because of the Type Erasure feature
+ of Java. Note that this method works fine if the any of the object fields are of generic type,
+ just the object itself should not be of a generic type. If the object is of generic type, use
+ toJson(Object, Type, Appendable)
instead.
++
src
- the object for which Json representation is to be created setting for Gsonwriter
- Writer to which the Json representation needs to be written
+JsonIOException
- if there was a problem writing to the writer+public void toJson(Object src, + Type typeOfSrc, + Appendable writer) + throws JsonIOException+
toJson(Object, Appendable)
instead.
++
src
- the object for which JSON representation is to be createdtypeOfSrc
- The specific genericized type of src. You can obtain
+ this type by using the TypeToken
class. For example,
+ to get the type for Collection<Foo>
, you should use:
+ + Type typeOfSrc = new TypeToken<Collection<Foo>>(){}.getType(); +
writer
- Writer to which the Json representation of src needs to be written.
+JsonIOException
- if there was a problem writing to the writer+public void toJson(Object src, + Type typeOfSrc, + JsonWriter writer) + throws JsonIOException+
src
of type typeOfSrc
to
+ writer
.
++
JsonIOException
- if there was a problem writing to the writer+public String toJson(JsonElement jsonElement)+
JsonElement
s into its equivalent JSON representation.
++
jsonElement
- root of a tree of JsonElement
s
++public void toJson(JsonElement jsonElement, + Appendable writer) + throws JsonIOException+
JsonElement
s.
++
jsonElement
- root of a tree of JsonElement
swriter
- Writer to which the Json representation needs to be written
+JsonIOException
- if there was a problem writing to the writer+public void toJson(JsonElement jsonElement, + JsonWriter writer) + throws JsonIOException+
jsonElement
to writer
.
++
JsonIOException
- if there was a problem writing to the writer+public <T> T fromJson(String json, + Class<T> classOfT) + throws JsonSyntaxException+
fromJson(String, Type)
. If you have the Json in a Reader
instead of
+ a String, use fromJson(Reader, Class)
instead.
++
T
- the type of the desired objectjson
- the string from which the object is to be deserializedclassOfT
- the class of T
+JsonSyntaxException
- if json is not a valid representation for an object of type
+ classOfT+public <T> T fromJson(String json, + Type typeOfT) + throws JsonSyntaxException+
fromJson(String, Class)
instead. If you have the Json in a Reader
instead of
+ a String, use fromJson(Reader, Type)
instead.
++
T
- the type of the desired objectjson
- the string from which the object is to be deserializedtypeOfT
- The specific genericized type of src. You can obtain this type by using the
+ TypeToken
class. For example, to get the type for
+ Collection<Foo>
, you should use:
+ + Type typeOfT = new TypeToken<Collection<Foo>>(){}.getType(); ++
JsonParseException
- if json is not a valid representation for an object of type typeOfT
+JsonSyntaxException
- if json is not a valid representation for an object of type+public <T> T fromJson(Reader json, + Class<T> classOfT) + throws JsonSyntaxException, + JsonIOException+
fromJson(Reader, Type)
. If you have the Json in a String form instead of a
+ Reader
, use fromJson(String, Class)
instead.
++
T
- the type of the desired objectjson
- the reader producing the Json from which the object is to be deserialized.classOfT
- the class of T
+JsonIOException
- if there was a problem reading from the Reader
+JsonSyntaxException
- if json is not a valid representation for an object of type+public <T> T fromJson(Reader json, + Type typeOfT) + throws JsonIOException, + JsonSyntaxException+
fromJson(Reader, Class)
instead. If you have the Json in a
+ String form instead of a Reader
, use fromJson(String, Type)
instead.
++
T
- the type of the desired objectjson
- the reader producing Json from which the object is to be deserializedtypeOfT
- The specific genericized type of src. You can obtain this type by using the
+ TypeToken
class. For example, to get the type for
+ Collection<Foo>
, you should use:
+ + Type typeOfT = new TypeToken<Collection<Foo>>(){}.getType(); ++
JsonIOException
- if there was a problem reading from the Reader
+JsonSyntaxException
- if json is not a valid representation for an object of type+public <T> T fromJson(JsonReader reader, + Type typeOfT) + throws JsonIOException, + JsonSyntaxException+
reader
and convert it to an object
+ of type typeOfT
.
+ Since Type is not parameterized by T, this method is type unsafe and should be used carefully
++
JsonIOException
- if there was a problem writing to the Reader
+JsonSyntaxException
- if json is not a valid representation for an object of type+public <T> T fromJson(JsonElement json, + Class<T> classOfT) + throws JsonSyntaxException+
fromJson(JsonElement, Type)
.
++
T
- the type of the desired objectjson
- the root of the parse tree of JsonElement
s from which the object is to
+ be deserializedclassOfT
- The class of T
+JsonSyntaxException
- if json is not a valid representation for an object of type typeOfT+public <T> T fromJson(JsonElement json, + Type typeOfT) + throws JsonSyntaxException+
fromJson(JsonElement, Class)
instead.
++
T
- the type of the desired objectjson
- the root of the parse tree of JsonElement
s from which the object is to
+ be deserializedtypeOfT
- The specific genericized type of src. You can obtain this type by using the
+ TypeToken
class. For example, to get the type for
+ Collection<Foo>
, you should use:
+ + Type typeOfT = new TypeToken<Collection<Foo>>(){}.getType(); ++
JsonSyntaxException
- if json is not a valid representation for an object of type typeOfT+public String toString()+
toString
in class Object
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.GsonBuilder ++
public final class GsonBuilder
+
Use this builder to construct a Gson
instance when you need to set configuration
+ options other than the default. For Gson
with default configuration, it is simpler to
+ use new Gson()
. GsonBuilder
is best used by creating it, and then invoking its
+ various configuration methods, and finally calling create.
The following is an example shows how to use the GsonBuilder
to construct a Gson
+ instance:
+
+
+ Gson gson = new GsonBuilder() + .registerTypeAdapter(Id.class, new IdTypeAdapter()) + .enableComplexMapKeySerialization() + .serializeNulls() + .setDateFormat(DateFormat.LONG) + .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE) + .setPrettyPrinting() + .setVersion(1.0) + .create(); ++ +
NOTES: +
Date
and its subclasses in Gson does
+ not contain time-zone information. So, if you are using date/time instances,
+ use GsonBuilder
and its setDateFormat
methods.+ +
+
+Constructor Summary | +|
---|---|
GsonBuilder()
+
++ Creates a GsonBuilder instance that can be used to build Gson with various configuration + settings. |
+
+Method Summary | +|
---|---|
+ GsonBuilder |
+addDeserializationExclusionStrategy(ExclusionStrategy strategy)
+
++ Configures Gson to apply the passed in exclusion strategy during deserialization. |
+
+ GsonBuilder |
+addSerializationExclusionStrategy(ExclusionStrategy strategy)
+
++ Configures Gson to apply the passed in exclusion strategy during serialization. |
+
+ Gson |
+create()
+
++ Creates a Gson instance based on the current configuration. |
+
+ GsonBuilder |
+disableHtmlEscaping()
+
++ By default, Gson escapes HTML characters such as < > etc. |
+
+ GsonBuilder |
+disableInnerClassSerialization()
+
++ Configures Gson to exclude inner classes during serialization. |
+
+ GsonBuilder |
+enableComplexMapKeySerialization()
+
++ Enabling this feature will only change the serialized form if the map key is + a complex type (i.e. |
+
+ GsonBuilder |
+excludeFieldsWithModifiers(int... modifiers)
+
++ Configures Gson to excludes all class fields that have the specified modifiers. |
+
+ GsonBuilder |
+excludeFieldsWithoutExposeAnnotation()
+
++ Configures Gson to exclude all fields from consideration for serialization or deserialization + that do not have the Expose annotation. |
+
+ GsonBuilder |
+generateNonExecutableJson()
+
++ Makes the output JSON non-executable in Javascript by prefixing the generated JSON with some + special text. |
+
+ GsonBuilder |
+registerTypeAdapter(Type type,
+ Object typeAdapter)
+
++ Configures Gson for custom serialization or deserialization. |
+
+ GsonBuilder |
+registerTypeHierarchyAdapter(Class<?> baseType,
+ Object typeAdapter)
+
++ Configures Gson for custom serialization or deserialization for an inheritance type hierarchy. |
+
+ GsonBuilder |
+serializeNulls()
+
++ Configure Gson to serialize null fields. |
+
+ GsonBuilder |
+serializeSpecialFloatingPointValues()
+
++ Section 2.4 of JSON specification disallows + special double values (NaN, Infinity, -Infinity). |
+
+ GsonBuilder |
+setDateFormat(int style)
+
++ Configures Gson to to serialize Date objects according to the style value provided. |
+
+ GsonBuilder |
+setDateFormat(int dateStyle,
+ int timeStyle)
+
++ Configures Gson to to serialize Date objects according to the style value provided. |
+
+ GsonBuilder |
+setDateFormat(String pattern)
+
++ Configures Gson to serialize Date objects according to the pattern provided. |
+
+ GsonBuilder |
+setExclusionStrategies(ExclusionStrategy... strategies)
+
++ Configures Gson to apply a set of exclusion strategies during both serialization and + deserialization. |
+
+ GsonBuilder |
+setFieldNamingPolicy(FieldNamingPolicy namingConvention)
+
++ Configures Gson to apply a specific naming policy to an object's field during serialization + and deserialization. |
+
+ GsonBuilder |
+setFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy)
+
++ Configures Gson to apply a specific naming policy strategy to an object's field during + serialization and deserialization. |
+
+ GsonBuilder |
+setLongSerializationPolicy(LongSerializationPolicy serializationPolicy)
+
++ Configures Gson to apply a specific serialization policy for Long and long
+ objects. |
+
+ GsonBuilder |
+setPrettyPrinting()
+
++ Configures Gson to output Json that fits in a page for pretty printing. |
+
+ GsonBuilder |
+setVersion(double ignoreVersionsAfter)
+
++ Configures Gson to enable versioning support. |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public GsonBuilder()+
create()
.
++
+Method Detail | +
---|
+public GsonBuilder setVersion(double ignoreVersionsAfter)+
+
ignoreVersionsAfter
- any field or type marked with a version higher than this value
+ are ignored during serialization or deserialization.
+GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder excludeFieldsWithModifiers(int... modifiers)+
+
modifiers
- the field modifiers. You must use the modifiers specified in the
+ Modifier
class. For example,
+ Modifier.TRANSIENT
,
+ Modifier.STATIC
.
+GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder generateNonExecutableJson()+
+
GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder excludeFieldsWithoutExposeAnnotation()+
Expose
annotation.
++
GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder serializeNulls()+
+
GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder enableComplexMapKeySerialization()+
toString()
+ on the key; however, when this is called then one of the following cases
+ apply:
+
+ Point
class, which contains an x and y coordinate,
+ to/from the JSON Primitive string value "(x,y)"
. The Java map would
+ then be serialized as a JsonObject
.
+
+ Below is an example: +
Gson gson = new GsonBuilder()
+ .register(Point.class, new MyPointTypeAdapter())
+ .enableComplexMapKeySerialization()
+ .create();
+
+ Map<Point, String> original = new LinkedHashMap<Point, String>();
+ original.put(new Point(5, 6), "a");
+ original.put(new Point(8, 8), "b");
+ System.out.println(gson.toJson(original, type));
+
+ The above code prints this JSON object: {
+ "(5,6)": "a",
+ "(8,8)": "b"
+ }
+
+
+ Point
class, but rather the default Gson serialization is applied.
+ In this case, some new Point(2,3)
would serialize as {"x":2,"y":5}
.
+
+ Given the assumption above, a Map<Point, String>
will be
+ serialize as an array of arrays (can be viewed as an entry set of pairs).
+
+
Below is an example of serializing complex types as JSON arrays: +
Gson gson = new GsonBuilder() + .enableComplexMapKeySerialization() + .create(); + + Map<Point, String> original = new LinkedHashMap<Point, String>(); + original.put(new Point(5, 6), "a"); + original.put(new Point(8, 8), "b"); + System.out.println(gson.toJson(original, type)); +
+ + The JSON output would look as follows: ++[ + [ + { + "x": 5, + "y": 6 + }, + "a" + ], + [ + { + "x": 8, + "y": 8 + }, + "b" + ] + ] +
+
GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder disableInnerClassSerialization()+
+
GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder setLongSerializationPolicy(LongSerializationPolicy serializationPolicy)+
Long
and long
+ objects.
++
serializationPolicy
- the particular policy to use for serializing longs.
+GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder setFieldNamingPolicy(FieldNamingPolicy namingConvention)+
+
namingConvention
- the JSON field naming convention to use for serialization and
+ deserialization.
+GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder setFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy)+
+
fieldNamingStrategy
- the actual naming strategy to apply to the fields
+GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder setExclusionStrategies(ExclusionStrategy... strategies)+
strategies
will be applied as a disjunction rule.
+ This means that if one of the strategies
suggests that a field (or class) should be
+ skipped then that field (or object) is skipped during serializaiton/deserialization.
++
strategies
- the set of strategy object to apply during object (de)serialization.
+GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder addSerializationExclusionStrategy(ExclusionStrategy strategy)+
+
strategy
- an exclusion strategy to apply during serialization.
+GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder addDeserializationExclusionStrategy(ExclusionStrategy strategy)+
+
strategy
- an exclusion strategy to apply during deserialization.
+GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder setPrettyPrinting()+
+
GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder disableHtmlEscaping()+
+
GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder setDateFormat(String pattern)+
Date
objects according to the pattern provided. You can
+ call this method or setDateFormat(int)
multiple times, but only the last invocation
+ will be used to decide the serialization format.
+
+ The date format will be used to serialize and deserialize Date
, Timestamp
and Date
.
+
+
Note that this pattern must abide by the convention provided by SimpleDateFormat
+ class. See the documentation in SimpleDateFormat
for more information on
+ valid date and time patterns.
+
pattern
- the pattern that dates will be serialized/deserialized to/from
+GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder setDateFormat(int style)+
Date
objects according to the style value provided.
+ You can call this method or setDateFormat(String)
multiple times, but only the last
+ invocation will be used to decide the serialization format.
+
+ Note that this style value should be one of the predefined constants in the
+ DateFormat
class. See the documentation in DateFormat
for more
+ information on the valid style constants.
+
style
- the predefined date style that date objects will be serialized/deserialized
+ to/from
+GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder setDateFormat(int dateStyle, + int timeStyle)+
Date
objects according to the style value provided.
+ You can call this method or setDateFormat(String)
multiple times, but only the last
+ invocation will be used to decide the serialization format.
+
+ Note that this style value should be one of the predefined constants in the
+ DateFormat
class. See the documentation in DateFormat
for more
+ information on the valid style constants.
+
dateStyle
- the predefined date style that date objects will be serialized/deserialized
+ to/fromtimeStyle
- the predefined style for the time portion of the date objects
+GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder registerTypeAdapter(Type type, + Object typeAdapter)+
InstanceCreator
, JsonSerializer
, and a
+ JsonDeserializer
. It is best used when a single object typeAdapter
implements
+ all the required interfaces for custom serialization with Gson. If an instance creator,
+ serializer or deserializer was previously registered for the specified type
, it is
+ overwritten.
++
type
- the type definition for the type adapter being registeredtypeAdapter
- This object must implement at least one of the InstanceCreator
,
+ JsonSerializer
, and a JsonDeserializer
interfaces.
+GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder registerTypeHierarchyAdapter(Class<?> baseType, + Object typeAdapter)+
InstanceCreator
, JsonSerializer
,
+ and a JsonDeserializer
. It is best used when a single object typeAdapter
+ implements all the required interfaces for custom serialization with Gson.
+ If an instance creator, serializer or deserializer was previously registered for the specified
+ type hierarchy, it is overwritten. If an instance creator, serializer or deserializer is
+ registered for a specific type in the type hierarchy, it will be invoked instead of the one
+ registered for the type hierarchy.
++
baseType
- the class definition for the type adapter being registered for the base class
+ or interfacetypeAdapter
- This object must implement at least one of the InstanceCreator
,
+ JsonSerializer
, and a JsonDeserializer
interfaces.
+GsonBuilder
object to fulfill the "Builder" pattern+public GsonBuilder serializeSpecialFloatingPointValues()+
Gson always accepts these special values during deserialization. However, it outputs
+ strictly compliant JSON. Hence, if it encounters a float value Float.NaN
,
+ Float.POSITIVE_INFINITY
, Float.NEGATIVE_INFINITY
, or a double value
+ Double.NaN
, Double.POSITIVE_INFINITY
, Double.NEGATIVE_INFINITY
, it
+ will throw an IllegalArgumentException
. This method provides a way to override the
+ default behavior when you know that the JSON receiver will be able to handle these special
+ values.
+
+
GsonBuilder
object to fulfill the "Builder" pattern+public Gson create()+
Gson
instance based on the current configuration. This method is free of
+ side-effects to this GsonBuilder
instance and hence can be called multiple times.
++
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
T
- the type of object that will be created by this implementation.public interface InstanceCreator<T>
+This interface is implemented to create instances of a class that does not define a no-args
+ constructor. If you can modify the class, you should instead add a private, or public
+ no-args constructor. However, that is not possible for library classes, such as JDK classes, or
+ a third-party library that you do not have source-code of. In such cases, you should define an
+ instance creator for the class. Implementations of this interface should be registered with
+ GsonBuilder.registerTypeAdapter(Type, Object)
method before Gson will be able to use
+ them.
+
Let us look at an example where defining an InstanceCreator might be useful. The
+ Id
class defined below does not have a default no-args constructor.
+ public class Id<T> { + private final Class<T> clazz; + private final long value; + public Id(Class<T> clazz, long value) { + this.clazz = clazz; + this.value = value; + } + } ++ +
If Gson encounters an object of type Id
during deserialization, it will throw an
+ exception. The easiest way to solve this problem will be to add a (public or private) no-args
+ constructor as follows:
+ private Id() { + this(Object.class, 0L); + } ++ +
However, let us assume that the developer does not have access to the source-code of the
+ Id
class, or does not want to define a no-args constructor for it. The developer
+ can solve this problem by defining an InstanceCreator
for Id
:
+ class IdInstanceCreator implements InstanceCreator<Id> { + public Id createInstance(Type type) { + return new Id(Object.class, 0L); + } + } ++ +
Note that it does not matter what the fields of the created instance contain since Gson will
+ overwrite them with the deserialized values specified in Json. You should also ensure that a
+ new object is returned, not a common object since its fields will be overwritten.
+ The developer will need to register IdInstanceCreator
with Gson as follows:
+ Gson gson = new GsonBuilder().registerTypeAdapter(Id.class, new IdInstanceCreator()).create(); ++
+ +
+
+Method Summary | +|
---|---|
+ T |
+createInstance(Type type)
+
++ Gson invokes this call-back method during deserialization to create an instance of the + specified type. |
+
+Method Detail | +
---|
+T createInstance(Type type)+
new
to create a new instance.
++
type
- the parameterized T represented as a Type
.
+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.JsonElement + com.google.gson.JsonArray ++
public final class JsonArray
+A class representing an array type in Json. An array is a list of JsonElement
s each of
+ which can be of a different type. This is an ordered list, meaning that the order in which
+ elements are added is preserved.
+
+ +
+
+Constructor Summary | +|
---|---|
JsonArray()
+
++ Creates an empty JsonArray. |
+
+Method Summary | +|
---|---|
+ void |
+add(JsonElement element)
+
++ Adds the specified element to self. |
+
+ void |
+addAll(JsonArray array)
+
++ Adds all the elements of the specified array to self. |
+
+ boolean |
+equals(Object o)
+
++ |
+
+ JsonElement |
+get(int i)
+
++ Returns the ith element of the array. |
+
+ BigDecimal |
+getAsBigDecimal()
+
++ convenience method to get this array as a BigDecimal if it contains a single element. |
+
+ BigInteger |
+getAsBigInteger()
+
++ convenience method to get this array as a BigInteger if it contains a single element. |
+
+ boolean |
+getAsBoolean()
+
++ convenience method to get this array as a boolean if it contains a single element. |
+
+ byte |
+getAsByte()
+
++ convenience method to get this element as a primitive byte value. |
+
+ char |
+getAsCharacter()
+
++ convenience method to get this element as a primitive character value. |
+
+ double |
+getAsDouble()
+
++ convenience method to get this array as a double if it contains a single element. |
+
+ float |
+getAsFloat()
+
++ convenience method to get this array as a float if it contains a single element. |
+
+ int |
+getAsInt()
+
++ convenience method to get this array as an integer if it contains a single element. |
+
+ long |
+getAsLong()
+
++ convenience method to get this array as a long if it contains a single element. |
+
+ Number |
+getAsNumber()
+
++ convenience method to get this array as a Number if it contains a single element. |
+
+ short |
+getAsShort()
+
++ convenience method to get this array as a primitive short if it contains a single element. |
+
+ String |
+getAsString()
+
++ convenience method to get this array as a String if it contains a single element. |
+
+ int |
+hashCode()
+
++ |
+
+ Iterator<JsonElement> |
+iterator()
+
++ Returns an iterator to navigate the elemetns of the array. |
+
+ int |
+size()
+
++ Returns the number of elements in the array. |
+
Methods inherited from class com.google.gson.JsonElement | +
---|
getAsJsonArray, getAsJsonNull, getAsJsonObject, getAsJsonPrimitive, isJsonArray, isJsonNull, isJsonObject, isJsonPrimitive, toString |
+
Methods inherited from class java.lang.Object | +
---|
getClass, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public JsonArray()+
+
+Method Detail | +
---|
+public void add(JsonElement element)+
+
element
- the element that needs to be added to the array.+public void addAll(JsonArray array)+
+
array
- the array whose elements need to be added to the array.+public int size()+
+
+public Iterator<JsonElement> iterator()+
+
iterator
in interface Iterable<JsonElement>
+public JsonElement get(int i)+
+
i
- the index of the element that is being sought.
+IndexOutOfBoundsException
- if i is negative or greater than or equal to the
+ size()
of the array.+public Number getAsNumber()+
Number
if it contains a single element.
++
getAsNumber
in class JsonElement
ClassCastException
- if the element in the array is of not a JsonPrimitive
and
+ is not a valid Number.
+IllegalStateException
- if the array has more than one element.+public String getAsString()+
String
if it contains a single element.
++
getAsString
in class JsonElement
ClassCastException
- if the element in the array is of not a JsonPrimitive
and
+ is not a valid String.
+IllegalStateException
- if the array has more than one element.+public double getAsDouble()+
+
getAsDouble
in class JsonElement
ClassCastException
- if the element in the array is of not a JsonPrimitive
and
+ is not a valid double.
+IllegalStateException
- if the array has more than one element.+public BigDecimal getAsBigDecimal()+
BigDecimal
if it contains a single element.
++
getAsBigDecimal
in class JsonElement
BigDecimal
if it is single element array.
+ClassCastException
- if the element in the array is of not a JsonPrimitive
.
+NumberFormatException
- if the element at index 0 is not a valid BigDecimal
.
+IllegalStateException
- if the array has more than one element.+public BigInteger getAsBigInteger()+
BigInteger
if it contains a single element.
++
getAsBigInteger
in class JsonElement
BigInteger
if it is single element array.
+ClassCastException
- if the element in the array is of not a JsonPrimitive
.
+NumberFormatException
- if the element at index 0 is not a valid BigInteger
.
+IllegalStateException
- if the array has more than one element.+public float getAsFloat()+
+
getAsFloat
in class JsonElement
ClassCastException
- if the element in the array is of not a JsonPrimitive
and
+ is not a valid float.
+IllegalStateException
- if the array has more than one element.+public long getAsLong()+
+
getAsLong
in class JsonElement
ClassCastException
- if the element in the array is of not a JsonPrimitive
and
+ is not a valid long.
+IllegalStateException
- if the array has more than one element.+public int getAsInt()+
+
getAsInt
in class JsonElement
ClassCastException
- if the element in the array is of not a JsonPrimitive
and
+ is not a valid integer.
+IllegalStateException
- if the array has more than one element.+public byte getAsByte()+
JsonElement
+
getAsByte
in class JsonElement
+public char getAsCharacter()+
JsonElement
+
getAsCharacter
in class JsonElement
+public short getAsShort()+
+
getAsShort
in class JsonElement
ClassCastException
- if the element in the array is of not a JsonPrimitive
and
+ is not a valid short.
+IllegalStateException
- if the array has more than one element.+public boolean getAsBoolean()+
+
getAsBoolean
in class JsonElement
ClassCastException
- if the element in the array is of not a JsonPrimitive
and
+ is not a valid boolean.
+IllegalStateException
- if the array has more than one element.+public boolean equals(Object o)+
equals
in class Object
+public int hashCode()+
hashCode
in class Object
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
public interface JsonDeserializationContext
+Context for deserialization that is passed to a custom deserializer during invocation of its
+ JsonDeserializer.deserialize(JsonElement, Type, JsonDeserializationContext)
+ method.
+
+ +
+
+Method Summary | +||
---|---|---|
+
+ |
+deserialize(JsonElement json,
+ Type typeOfT)
+
++ Invokes default deserialization on the specified object. |
+
+Method Detail | +
---|
+<T> T deserialize(JsonElement json, + Type typeOfT) + throws JsonParseException+
JsonDeserializer.deserialize(JsonElement, Type, JsonDeserializationContext)
method. Doing
+ so will result in an infinite loop since Gson will in-turn call the custom deserializer again.
++
T
- The type of the deserialized object.json
- the parse tree.typeOfT
- type of the expected return value.
+JsonParseException
- if the parse tree does not contain expected data.
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
T
- type for which the deserializer is being registered. It is possible that a
+ deserializer may be asked to deserialize a specific generic type of the T.public interface JsonDeserializer<T>
+
Interface representing a custom deserializer for Json. You should write a custom
+ deserializer, if you are not happy with the default deserialization done by Gson. You will
+ also need to register this deserializer through
+ GsonBuilder.registerTypeAdapter(Type, Object)
.
Let us look at example where defining a deserializer will be useful. The Id
class
+ defined below has two fields: clazz
and value
.
+ public class Id<T> { + private final Class<T> clazz; + private final long value; + public Id(Class<T> clazz, long value) { + this.clazz = clazz; + this.value = value; + } + public long getValue() { + return value; + } + } ++ +
The default deserialization of Id(com.foo.MyObject.class, 20L)
will require the
+ Json string to be {"clazz":com.foo.MyObject,"value":20}
. Suppose, you already know
+ the type of the field that the Id
will be deserialized into, and hence just want to
+ deserialize it from a Json string 20
. You can achieve that by writing a custom
+ deserializer:
+ class IdDeserializer implements JsonDeserializer<Id>() { + public Id deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + return new Id((Class)typeOfT, id.getValue()); + } ++ +
You will also need to register IdDeserializer
with Gson as follows:
+ Gson gson = new GsonBuilder().registerTypeAdapter(Id.class, new IdDeserializer()).create(); ++
+ +
+
+Method Summary | +|
---|---|
+ T |
+deserialize(JsonElement json,
+ Type typeOfT,
+ JsonDeserializationContext context)
+
++ Gson invokes this call-back method during deserialization when it encounters a field of the + specified type. |
+
+Method Detail | +
---|
+T deserialize(JsonElement json, + Type typeOfT, + JsonDeserializationContext context) + throws JsonParseException+
In the implementation of this call-back method, you should consider invoking
+ JsonDeserializationContext.deserialize(JsonElement, Type)
method to create objects
+ for any non-trivial field of the returned object. However, you should never invoke it on the
+ the same type passing json
since that will cause an infinite loop (Gson will call your
+ call-back method again).
+
+
json
- The Json data being deserializedtypeOfT
- The type of the Object to deserialize to
+T
+JsonParseException
- if json is not in the expected format of typeofT
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.JsonElement ++
public abstract class JsonElement
+A class representing an element of Json. It could either be a JsonObject
, a
+ JsonArray
, a JsonPrimitive
or a JsonNull
.
+
+ +
+
+Constructor Summary | +|
---|---|
JsonElement()
+
++ |
+
+Method Summary | +|
---|---|
+ BigDecimal |
+getAsBigDecimal()
+
++ convenience method to get this element as a BigDecimal . |
+
+ BigInteger |
+getAsBigInteger()
+
++ convenience method to get this element as a BigInteger . |
+
+ boolean |
+getAsBoolean()
+
++ convenience method to get this element as a boolean value. |
+
+ byte |
+getAsByte()
+
++ convenience method to get this element as a primitive byte value. |
+
+ char |
+getAsCharacter()
+
++ convenience method to get this element as a primitive character value. |
+
+ double |
+getAsDouble()
+
++ convenience method to get this element as a primitive double value. |
+
+ float |
+getAsFloat()
+
++ convenience method to get this element as a primitive float value. |
+
+ int |
+getAsInt()
+
++ convenience method to get this element as a primitive integer value. |
+
+ JsonArray |
+getAsJsonArray()
+
++ convenience method to get this element as a JsonArray . |
+
+ JsonNull |
+getAsJsonNull()
+
++ convenience method to get this element as a JsonNull . |
+
+ JsonObject |
+getAsJsonObject()
+
++ convenience method to get this element as a JsonObject . |
+
+ JsonPrimitive |
+getAsJsonPrimitive()
+
++ convenience method to get this element as a JsonPrimitive . |
+
+ long |
+getAsLong()
+
++ convenience method to get this element as a primitive long value. |
+
+ Number |
+getAsNumber()
+
++ convenience method to get this element as a Number . |
+
+ short |
+getAsShort()
+
++ convenience method to get this element as a primitive short value. |
+
+ String |
+getAsString()
+
++ convenience method to get this element as a string value. |
+
+ boolean |
+isJsonArray()
+
++ provides check for verifying if this element is an array or not. |
+
+ boolean |
+isJsonNull()
+
++ provides check for verifying if this element represents a null value or not. |
+
+ boolean |
+isJsonObject()
+
++ provides check for verifying if this element is a Json object or not. |
+
+ boolean |
+isJsonPrimitive()
+
++ provides check for verifying if this element is a primitive or not. |
+
+ String |
+toString()
+
++ Returns a String representation of this element. |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public JsonElement()+
+Method Detail | +
---|
+public boolean isJsonArray()+
+
JsonArray
, false otherwise.+public boolean isJsonObject()+
+
JsonObject
, false otherwise.+public boolean isJsonPrimitive()+
+
JsonPrimitive
, false otherwise.+public boolean isJsonNull()+
+
JsonNull
, false otherwise.+public JsonObject getAsJsonObject()+
JsonObject
. If the element is of some
+ other type, a ClassCastException
will result. Hence it is best to use this method
+ after ensuring that this element is of the desired type by calling isJsonObject()
+ first.
++
JsonObject
.
+IllegalStateException
- if the element is of another type.+public JsonArray getAsJsonArray()+
JsonArray
. If the element is of some
+ other type, a ClassCastException
will result. Hence it is best to use this method
+ after ensuring that this element is of the desired type by calling isJsonArray()
+ first.
++
JsonArray
.
+IllegalStateException
- if the element is of another type.+public JsonPrimitive getAsJsonPrimitive()+
JsonPrimitive
. If the element is of some
+ other type, a ClassCastException
will result. Hence it is best to use this method
+ after ensuring that this element is of the desired type by calling isJsonPrimitive()
+ first.
++
JsonPrimitive
.
+IllegalStateException
- if the element is of another type.+public JsonNull getAsJsonNull()+
JsonNull
. If the element is of some
+ other type, a ClassCastException
will result. Hence it is best to use this method
+ after ensuring that this element is of the desired type by calling isJsonNull()
+ first.
++
JsonNull
.
+IllegalStateException
- if the element is of another type.+public boolean getAsBoolean()+
+
ClassCastException
- if the element is of not a JsonPrimitive
and is not a valid
+ boolean value.
+IllegalStateException
- if the element is of the type JsonArray
but contains
+ more than a single element.+public Number getAsNumber()+
Number
.
++
Number
.
+ClassCastException
- if the element is of not a JsonPrimitive
and is not a valid
+ number.
+IllegalStateException
- if the element is of the type JsonArray
but contains
+ more than a single element.+public String getAsString()+
+
ClassCastException
- if the element is of not a JsonPrimitive
and is not a valid
+ string value.
+IllegalStateException
- if the element is of the type JsonArray
but contains
+ more than a single element.+public double getAsDouble()+
+
ClassCastException
- if the element is of not a JsonPrimitive
and is not a valid
+ double value.
+IllegalStateException
- if the element is of the type JsonArray
but contains
+ more than a single element.+public float getAsFloat()+
+
ClassCastException
- if the element is of not a JsonPrimitive
and is not a valid
+ float value.
+IllegalStateException
- if the element is of the type JsonArray
but contains
+ more than a single element.+public long getAsLong()+
+
ClassCastException
- if the element is of not a JsonPrimitive
and is not a valid
+ long value.
+IllegalStateException
- if the element is of the type JsonArray
but contains
+ more than a single element.+public int getAsInt()+
+
ClassCastException
- if the element is of not a JsonPrimitive
and is not a valid
+ integer value.
+IllegalStateException
- if the element is of the type JsonArray
but contains
+ more than a single element.+public byte getAsByte()+
+
ClassCastException
- if the element is of not a JsonPrimitive
and is not a valid
+ byte value.
+IllegalStateException
- if the element is of the type JsonArray
but contains
+ more than a single element.+public char getAsCharacter()+
+
ClassCastException
- if the element is of not a JsonPrimitive
and is not a valid
+ char value.
+IllegalStateException
- if the element is of the type JsonArray
but contains
+ more than a single element.+public BigDecimal getAsBigDecimal()+
BigDecimal
.
++
BigDecimal
.
+ClassCastException
- if the element is of not a JsonPrimitive
.
+ * @throws NumberFormatException if the element is not a valid BigDecimal
.
+IllegalStateException
- if the element is of the type JsonArray
but contains
+ more than a single element.+public BigInteger getAsBigInteger()+
BigInteger
.
++
BigInteger
.
+ClassCastException
- if the element is of not a JsonPrimitive
.
+NumberFormatException
- if the element is not a valid BigInteger
.
+IllegalStateException
- if the element is of the type JsonArray
but contains
+ more than a single element.+public short getAsShort()+
+
ClassCastException
- if the element is of not a JsonPrimitive
and is not a valid
+ short value.
+IllegalStateException
- if the element is of the type JsonArray
but contains
+ more than a single element.+public String toString()+
+
toString
in class Object
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + java.lang.Throwable + java.lang.Exception + java.lang.RuntimeException + com.google.gson.JsonParseException + com.google.gson.JsonIOException ++
public final class JsonIOException
+This exception is raised when Gson was unable to read an input stream + or write to one. +
+ +
+
+Constructor Summary | +|
---|---|
JsonIOException(String msg)
+
++ |
+|
JsonIOException(String msg,
+ Throwable cause)
+
++ |
+|
JsonIOException(Throwable cause)
+
++ Creates exception with the specified cause. |
+
+Method Summary | +
---|
Methods inherited from class java.lang.Throwable | +
---|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public JsonIOException(String msg)+
+public JsonIOException(String msg, + Throwable cause)+
+public JsonIOException(Throwable cause)+
JsonIOException(String, Throwable)
instead if you can describe what happened.
++
cause
- root exception that caused this exception to be thrown.
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.JsonElement + com.google.gson.JsonNull ++
public final class JsonNull
+A class representing a Json null
value.
+
+ +
+
+Field Summary | +|
---|---|
+static JsonNull |
+INSTANCE
+
++ singleton for JsonNull |
+
+Constructor Summary | +|
---|---|
JsonNull()
+
++ Deprecated. |
+
+Method Summary | +|
---|---|
+ boolean |
+equals(Object other)
+
++ All instances of JsonNull are the same |
+
+ int |
+hashCode()
+
++ All instances of JsonNull have the same hash code since they are indistinguishable |
+
Methods inherited from class com.google.gson.JsonElement | +
---|
getAsBigDecimal, getAsBigInteger, getAsBoolean, getAsByte, getAsCharacter, getAsDouble, getAsFloat, getAsInt, getAsJsonArray, getAsJsonNull, getAsJsonObject, getAsJsonPrimitive, getAsLong, getAsNumber, getAsShort, getAsString, isJsonArray, isJsonNull, isJsonObject, isJsonPrimitive, toString |
+
Methods inherited from class java.lang.Object | +
---|
getClass, notify, notifyAll, wait, wait, wait |
+
+Field Detail | +
---|
+public static final JsonNull INSTANCE+
+
+Constructor Detail | +
---|
+@Deprecated +public JsonNull()+
+
INSTANCE
instead
++
+Method Detail | +
---|
+public int hashCode()+
+
hashCode
in class Object
+public boolean equals(Object other)+
+
equals
in class Object
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.JsonElement + com.google.gson.JsonObject ++
public final class JsonObject
+A class representing an object type in Json. An object consists of name-value pairs where names
+ are strings, and values are any other type of JsonElement
. This allows for a creating a
+ tree of JsonElements. The member elements of this object are maintained in order they were added.
+
+ +
+
+Constructor Summary | +|
---|---|
JsonObject()
+
++ Creates an empty JsonObject. |
+
+Method Summary | +|
---|---|
+ void |
+add(String property,
+ JsonElement value)
+
++ Adds a member, which is a name-value pair, to self. |
+
+ void |
+addProperty(String property,
+ Boolean value)
+
++ Convenience method to add a boolean member. |
+
+ void |
+addProperty(String property,
+ Character value)
+
++ Convenience method to add a char member. |
+
+ void |
+addProperty(String property,
+ Number value)
+
++ Convenience method to add a primitive member. |
+
+ void |
+addProperty(String property,
+ String value)
+
++ Convenience method to add a primitive member. |
+
+ Set<Map.Entry<String,JsonElement>> |
+entrySet()
+
++ Returns a set of members of this object. |
+
+ boolean |
+equals(Object o)
+
++ |
+
+ JsonElement |
+get(String memberName)
+
++ Returns the member with the specified name. |
+
+ JsonArray |
+getAsJsonArray(String memberName)
+
++ Convenience method to get the specified member as a JsonArray. |
+
+ JsonObject |
+getAsJsonObject(String memberName)
+
++ Convenience method to get the specified member as a JsonObject. |
+
+ JsonPrimitive |
+getAsJsonPrimitive(String memberName)
+
++ Convenience method to get the specified member as a JsonPrimitive element. |
+
+ boolean |
+has(String memberName)
+
++ Convenience method to check if a member with the specified name is present in this object. |
+
+ int |
+hashCode()
+
++ |
+
+ JsonElement |
+remove(String property)
+
++ Removes the property from this JsonObject . |
+
Methods inherited from class com.google.gson.JsonElement | +
---|
getAsBigDecimal, getAsBigInteger, getAsBoolean, getAsByte, getAsCharacter, getAsDouble, getAsFloat, getAsInt, getAsJsonArray, getAsJsonNull, getAsJsonObject, getAsJsonPrimitive, getAsLong, getAsNumber, getAsShort, getAsString, isJsonArray, isJsonNull, isJsonObject, isJsonPrimitive, toString |
+
Methods inherited from class java.lang.Object | +
---|
getClass, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public JsonObject()+
+
+Method Detail | +
---|
+public void add(String property, + JsonElement value)+
+
property
- name of the member.value
- the member object.+public JsonElement remove(String property)+
property
from this JsonObject
.
++
property
- name of the member that should be removed.
+JsonElement
object that is being removed.+public void addProperty(String property, + String value)+
+
property
- name of the member.value
- the string value associated with the member.+public void addProperty(String property, + Number value)+
+
property
- name of the member.value
- the number value associated with the member.+public void addProperty(String property, + Boolean value)+
+
property
- name of the member.value
- the number value associated with the member.+public void addProperty(String property, + Character value)+
+
property
- name of the member.value
- the number value associated with the member.+public Set<Map.Entry<String,JsonElement>> entrySet()+
+
+public boolean has(String memberName)+
+
memberName
- name of the member that is being checked for presence.
++public JsonElement get(String memberName)+
+
memberName
- name of the member that is being requested.
++public JsonPrimitive getAsJsonPrimitive(String memberName)+
+
memberName
- name of the member being requested.
++public JsonArray getAsJsonArray(String memberName)+
+
memberName
- name of the member being requested.
++public JsonObject getAsJsonObject(String memberName)+
+
memberName
- name of the member being requested.
++public boolean equals(Object o)+
equals
in class Object
+public int hashCode()+
hashCode
in class Object
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + java.lang.Throwable + java.lang.Exception + java.lang.RuntimeException + com.google.gson.JsonParseException ++
public class JsonParseException
+This exception is raised if there is a serious issue that occurs during parsing of a Json + string. One of the main usages for this class is for the Gson infrastructure. If the incoming + Json is bad/malicious, an instance of this exception is raised. + +
This exception is a RuntimeException
because it is exposed to the client. Using a
+ RuntimeException
avoids bad coding practices on the client side where they catch the
+ exception and do nothing. It is often the case that you want to blow up if there is a parsing
+ error (i.e. often clients do not know how to recover from a JsonParseException
.
+ +
+
+Constructor Summary | +|
---|---|
JsonParseException(String msg)
+
++ Creates exception with the specified message. |
+|
JsonParseException(String msg,
+ Throwable cause)
+
++ Creates exception with the specified message and cause. |
+|
JsonParseException(Throwable cause)
+
++ Creates exception with the specified cause. |
+
+Method Summary | +
---|
Methods inherited from class java.lang.Throwable | +
---|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public JsonParseException(String msg)+
JsonParseException(String, Throwable)
instead.
++
msg
- error message describing a possible cause of this exception.+public JsonParseException(String msg, + Throwable cause)+
+
msg
- error message describing what happened.cause
- root exception that caused this exception to be thrown.+public JsonParseException(Throwable cause)+
JsonParseException(String, Throwable)
instead if you can describe what happened.
++
cause
- root exception that caused this exception to be thrown.
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.JsonParser ++
public final class JsonParser
+A parser to parse Json into a parse tree of JsonElement
s
+
+ +
+
+Constructor Summary | +|
---|---|
JsonParser()
+
++ |
+
+Method Summary | +|
---|---|
+ JsonElement |
+parse(JsonReader json)
+
++ Returns the next value from the JSON stream as a parse tree. |
+
+ JsonElement |
+parse(Reader json)
+
++ Parses the specified JSON string into a parse tree |
+
+ JsonElement |
+parse(String json)
+
++ Parses the specified JSON string into a parse tree |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public JsonParser()+
+Method Detail | +
---|
+public JsonElement parse(String json) + throws JsonSyntaxException+
+
json
- JSON text
+JsonElement
s corresponding to the specified JSON
+JsonParseException
- if the specified text is not valid JSON
+JsonSyntaxException
+public JsonElement parse(Reader json) + throws JsonIOException, + JsonSyntaxException+
+
json
- JSON text
+JsonElement
s corresponding to the specified JSON
+JsonParseException
- if the specified text is not valid JSON
+JsonIOException
+JsonSyntaxException
+public JsonElement parse(JsonReader json) + throws JsonIOException, + JsonSyntaxException+
+
JsonParseException
- if there is an IOException or if the specified
+ text is not valid JSON
+JsonIOException
+JsonSyntaxException
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.JsonElement + com.google.gson.JsonPrimitive ++
public final class JsonPrimitive
+A class representing a Json primitive value. A primitive value + is either a String, a Java primitive, or a Java primitive + wrapper type. +
+ +
+
+Constructor Summary | +|
---|---|
JsonPrimitive(Boolean bool)
+
++ Create a primitive containing a boolean value. |
+|
JsonPrimitive(Character c)
+
++ Create a primitive containing a character. |
+|
JsonPrimitive(Number number)
+
++ Create a primitive containing a Number . |
+|
JsonPrimitive(String string)
+
++ Create a primitive containing a String value. |
+
+Method Summary | +|
---|---|
+ boolean |
+equals(Object obj)
+
++ |
+
+ BigDecimal |
+getAsBigDecimal()
+
++ convenience method to get this element as a BigDecimal . |
+
+ BigInteger |
+getAsBigInteger()
+
++ convenience method to get this element as a BigInteger . |
+
+ boolean |
+getAsBoolean()
+
++ convenience method to get this element as a boolean value. |
+
+ byte |
+getAsByte()
+
++ convenience method to get this element as a primitive byte value. |
+
+ char |
+getAsCharacter()
+
++ convenience method to get this element as a primitive character value. |
+
+ double |
+getAsDouble()
+
++ convenience method to get this element as a primitive double. |
+
+ float |
+getAsFloat()
+
++ convenience method to get this element as a float. |
+
+ int |
+getAsInt()
+
++ convenience method to get this element as a primitive integer. |
+
+ long |
+getAsLong()
+
++ convenience method to get this element as a primitive long. |
+
+ Number |
+getAsNumber()
+
++ convenience method to get this element as a Number. |
+
+ short |
+getAsShort()
+
++ convenience method to get this element as a primitive short. |
+
+ String |
+getAsString()
+
++ convenience method to get this element as a String. |
+
+ int |
+hashCode()
+
++ |
+
+ boolean |
+isBoolean()
+
++ Check whether this primitive contains a boolean value. |
+
+ boolean |
+isNumber()
+
++ Check whether this primitive contains a Number. |
+
+ boolean |
+isString()
+
++ Check whether this primitive contains a String value. |
+
Methods inherited from class com.google.gson.JsonElement | +
---|
getAsJsonArray, getAsJsonNull, getAsJsonObject, getAsJsonPrimitive, isJsonArray, isJsonNull, isJsonObject, isJsonPrimitive, toString |
+
Methods inherited from class java.lang.Object | +
---|
getClass, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public JsonPrimitive(Boolean bool)+
+
bool
- the value to create the primitive with.+public JsonPrimitive(Number number)+
Number
.
++
number
- the value to create the primitive with.+public JsonPrimitive(String string)+
+
string
- the value to create the primitive with.+public JsonPrimitive(Character c)+
+
c
- the value to create the primitive with.+Method Detail | +
---|
+public boolean isBoolean()+
+
+public boolean getAsBoolean()+
+
getAsBoolean
in class JsonElement
+public boolean isNumber()+
+
+public Number getAsNumber()+
+
getAsNumber
in class JsonElement
NumberFormatException
- if the value contained is not a valid Number.+public boolean isString()+
+
+public String getAsString()+
+
getAsString
in class JsonElement
+public double getAsDouble()+
+
getAsDouble
in class JsonElement
NumberFormatException
- if the value contained is not a valid double.+public BigDecimal getAsBigDecimal()+
BigDecimal
.
++
getAsBigDecimal
in class JsonElement
BigDecimal
.
+NumberFormatException
- if the value contained is not a valid BigDecimal
.+public BigInteger getAsBigInteger()+
BigInteger
.
++
getAsBigInteger
in class JsonElement
BigInteger
.
+NumberFormatException
- if the value contained is not a valid BigInteger
.+public float getAsFloat()+
+
getAsFloat
in class JsonElement
NumberFormatException
- if the value contained is not a valid float.+public long getAsLong()+
+
getAsLong
in class JsonElement
NumberFormatException
- if the value contained is not a valid long.+public short getAsShort()+
+
getAsShort
in class JsonElement
NumberFormatException
- if the value contained is not a valid short value.+public int getAsInt()+
+
getAsInt
in class JsonElement
NumberFormatException
- if the value contained is not a valid integer.+public byte getAsByte()+
JsonElement
+
getAsByte
in class JsonElement
+public char getAsCharacter()+
JsonElement
+
getAsCharacter
in class JsonElement
+public int hashCode()+
hashCode
in class Object
+public boolean equals(Object obj)+
equals
in class Object
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
public interface JsonSerializationContext
+Context for serialization that is passed to a custom serializer during invocation of its
+ JsonSerializer.serialize(Object, Type, JsonSerializationContext)
method.
+
+ +
+
+Method Summary | +|
---|---|
+ JsonElement |
+serialize(Object src)
+
++ Invokes default serialization on the specified object. |
+
+ JsonElement |
+serialize(Object src,
+ Type typeOfSrc)
+
++ Invokes default serialization on the specified object passing the specific type information. |
+
+Method Detail | +
---|
+JsonElement serialize(Object src)+
+
src
- the object that needs to be serialized.
+JsonElement
s corresponding to the serialized form of src
.+JsonElement serialize(Object src, + Type typeOfSrc)+
JsonSerializer.serialize(Object, Type, JsonSerializationContext)
method. Doing
+ so will result in an infinite loop since Gson will in-turn call the custom serializer again.
++
src
- the object that needs to be serialized.typeOfSrc
- the actual genericized type of src object.
+JsonElement
s corresponding to the serialized form of src
.
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
T
- type for which the serializer is being registered. It is possible that a serializer
+ may be asked to serialize a specific generic type of the T.public interface JsonSerializer<T>
+Interface representing a custom serializer for Json. You should write a custom serializer, if
+ you are not happy with the default serialization done by Gson. You will also need to register
+ this serializer through GsonBuilder.registerTypeAdapter(Type, Object)
.
+
+
Let us look at example where defining a serializer will be useful. The Id
class
+ defined below has two fields: clazz
and value
.
+ public class Id<T> { + private final Class<T> clazz; + private final long value; + + public Id(Class<T> clazz, long value) { + this.clazz = clazz; + this.value = value; + } + + public long getValue() { + return value; + } + } ++ +
The default serialization of Id(com.foo.MyObject.class, 20L)
will be
+ {"clazz":com.foo.MyObject,"value":20}
. Suppose, you just want the output to be
+ the value instead, which is 20
in this case. You can achieve that by writing a custom
+ serializer:
+ class IdSerializer implements JsonSerializer<Id>() { + public JsonElement serialize(Id id, Type typeOfId, JsonSerializationContext context) { + return new JsonPrimitive(id.getValue()); + } + } ++ +
You will also need to register IdSerializer
with Gson as follows:
+ Gson gson = new GsonBuilder().registerTypeAdapter(Id.class, new IdSerializer()).create(); ++
+ +
+
+Method Summary | +|
---|---|
+ JsonElement |
+serialize(T src,
+ Type typeOfSrc,
+ JsonSerializationContext context)
+
++ Gson invokes this call-back method during serialization when it encounters a field of the + specified type. |
+
+Method Detail | +
---|
+JsonElement serialize(T src, + Type typeOfSrc, + JsonSerializationContext context)+
In the implementation of this call-back method, you should consider invoking
+ JsonSerializationContext.serialize(Object, Type)
method to create JsonElements for any
+ non-trivial field of the src
object. However, you should never invoke it on the
+ src
object itself since that will cause an infinite loop (Gson will call your
+ call-back method again).
+
src
- the object that needs to be converted to Json.typeOfSrc
- the actual type (fully genericized version) of the source object.
+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.JsonStreamParser ++
public final class JsonStreamParser
+A streaming parser that allows reading of multiple JsonElement
s from the specified reader
+ asynchronously.
+
+
This class is conditionally thread-safe (see Item 70, Effective Java second edition). To + properly use this class across multiple threads, you will need to add some external + synchronization. For example: + +
+ JsonStreamParser parser = new JsonStreamParser("['first'] {'second':10} 'third'"); + JsonElement element; + synchronized (parser) { // synchronize on an object shared by threads + if (parser.hasNext()) { + element = parser.next(); + } + } ++
+ +
+
+Constructor Summary | +|
---|---|
JsonStreamParser(Reader reader)
+
++ |
+|
JsonStreamParser(String json)
+
++ |
+
+Method Summary | +|
---|---|
+ boolean |
+hasNext()
+
++ Returns true if a JsonElement is available on the input for consumption |
+
+ JsonElement |
+next()
+
++ Returns the next available JsonElement on the reader. |
+
+ void |
+remove()
+
++ This optional Iterator method is not relevant for stream parsing and hence is not
+ implemented. |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public JsonStreamParser(String json)+
json
- The string containing JSON elements concatenated to each other.+public JsonStreamParser(Reader reader)+
reader
- The data stream containing JSON elements concatenated to each other.+Method Detail | +
---|
+public JsonElement next() + throws JsonParseException+
JsonElement
on the reader. Null if none available.
++
next
in interface Iterator<JsonElement>
JsonElement
on the reader. Null if none available.
+JsonParseException
- if the incoming stream is malformed JSON.+public boolean hasNext()+
JsonElement
is available on the input for consumption
++
hasNext
in interface Iterator<JsonElement>
JsonElement
is available on the input, false otherwise+public void remove()+
Iterator
method is not relevant for stream parsing and hence is not
+ implemented.
++
remove
in interface Iterator<JsonElement>
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + java.lang.Throwable + java.lang.Exception + java.lang.RuntimeException + com.google.gson.JsonParseException + com.google.gson.JsonSyntaxException ++
public final class JsonSyntaxException
+This exception is raised when Gson attempts to read (or write) a malformed + JSON element. +
+ +
+
+Constructor Summary | +|
---|---|
JsonSyntaxException(String msg)
+
++ |
+|
JsonSyntaxException(String msg,
+ Throwable cause)
+
++ |
+|
JsonSyntaxException(Throwable cause)
+
++ Creates exception with the specified cause. |
+
+Method Summary | +
---|
Methods inherited from class java.lang.Throwable | +
---|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public JsonSyntaxException(String msg)+
+public JsonSyntaxException(String msg, + Throwable cause)+
+public JsonSyntaxException(Throwable cause)+
JsonSyntaxException(String, Throwable)
instead if you can
+ describe what actually happened.
++
cause
- root exception that caused this exception to be thrown.
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | ++DETAIL: ENUM CONSTANTS | FIELD | METHOD | +
+java.lang.Object + java.lang.Enum<LongSerializationPolicy> + com.google.gson.LongSerializationPolicy ++
public enum LongSerializationPolicy
+Defines the expected format for a long
or Long
type when its serialized.
+
+ +
+
+Enum Constant Summary | +|
---|---|
DEFAULT
+
++ This is the "default" serialization policy that will output a long object as a JSON
+ number. |
+|
STRING
+
++ Serializes a long value as a quoted string. |
+
+Method Summary | +|
---|---|
+ JsonElement |
+serialize(Long value)
+
++ Serialize this value using this serialization policy. |
+
+static LongSerializationPolicy |
+valueOf(String name)
+
++ Returns the enum constant of this type with the specified name. |
+
+static LongSerializationPolicy[] |
+values()
+
++ Returns an array containing the constants of this enum type, in +the order they are declared. |
+
Methods inherited from class java.lang.Enum | +
---|
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
+
Methods inherited from class java.lang.Object | +
---|
getClass, notify, notifyAll, wait, wait, wait |
+
+Enum Constant Detail | +
---|
+public static final LongSerializationPolicy DEFAULT+
long
object as a JSON
+ number. For example, assume an object has a long field named "f" then the serialized output
+ would be:
+ {"f":123}
.
++
+public static final LongSerializationPolicy STRING+
{"f":"123"}
.
++
+Method Detail | +
---|
+public static LongSerializationPolicy[] values()+
+for (LongSerializationPolicy c : LongSerializationPolicy.values()) + System.out.println(c); ++
+
+public static LongSerializationPolicy valueOf(String name)+
+
name
- the name of the enum constant to be returned.
+IllegalArgumentException
- if this enum type has no constant
+with the specified name
+NullPointerException
- if the argument is null+public JsonElement serialize(Long value)+
value
using this serialization policy.
++
value
- the long value to be serialized into a JsonElement
+value
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | ++DETAIL: ENUM CONSTANTS | FIELD | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: REQUIRED | OPTIONAL | ++DETAIL: ELEMENT | +
@Retention(value=RUNTIME) +@Target(value=FIELD) +public @interface Expose
+An annotation that indicates this member should be exposed for JSON + serialization or deserialization. + +
This annotation has no effect unless you build Gson
+ with a GsonBuilder
and invoke
+ GsonBuilder.excludeFieldsWithoutExposeAnnotation()
+ method.
Here is an example of how this annotation is meant to be used: +
+ public class User { + @Expose private String firstName; + @Expose(serialize = false) private String lastName; + @Expose (serialize = false, deserialize = false) private String emailAddress; + private String password; + } ++ If you created Gson with
new Gson()
, the toJson()
and fromJson()
+ methods will use the password
field along-with firstName
, lastName
,
+ and emailAddress
for serialization and deserialization. However, if you created Gson
+ with Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create()
+ then the toJson()
and fromJson()
methods of Gson will exclude the
+ password
field. This is because the password
field is not marked with the
+ @Expose
annotation. Gson will also exclude lastName
and emailAddress
+ from serialization since serialize
is set to false
. Similarly, Gson will
+ exclude emailAddress
from deserialization since deserialize
is set to false.
+
+ Note that another way to achieve the same effect would have been to just mark the
+ password
field as transient
, and Gson would have excluded it even with default
+ settings. The @Expose
annotation is useful in a style of programming where you want to
+ explicitly specify all fields that should get considered for serialization or deserialization.
+
+ +
+
+Optional Element Summary | +|
---|---|
+ boolean |
+deserialize
+
++ If true , the field marked with this annotation is deserialized from the JSON. |
+
+ boolean |
+serialize
+
++ If true , the field marked with this annotation is written out in the JSON while
+ serializing. |
+
+public abstract boolean serialize+
true
, the field marked with this annotation is written out in the JSON while
+ serializing. If false
, the field marked with this annotation is skipped from the
+ serialized output. Defaults to true
.
++
+public abstract boolean deserialize+
true
, the field marked with this annotation is deserialized from the JSON.
+ If false
, the field marked with this annotation is skipped during deserialization.
+ Defaults to true
.
++
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: REQUIRED | OPTIONAL | ++DETAIL: ELEMENT | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: REQUIRED | OPTIONAL | ++DETAIL: ELEMENT | +
@Retention(value=RUNTIME) +@Target(value=FIELD) +public @interface SerializedName
+An annotation that indicates this member should be serialized to JSON with + the provided name value as its field name. + +
This annotation will override any FieldNamingPolicy
, including
+ the default field naming policy, that may have been set on the Gson
+ instance. A different naming policy can set using the GsonBuilder
class. See
+ GsonBuilder.setFieldNamingPolicy(com.google.gson.FieldNamingPolicy)
+ for more information.
Here is an example of how this annotation is meant to be used:
++ public class SomeClassWithFields { + @SerializedName("name") private final String someField; + private final String someOtherField; + + public SomeClassWithFields(String a, String b) { + this.someField = a; + this.someOtherField = b; + } + } ++ +
The following shows the output that is generated when serializing an instance of the + above example class:
++ SomeClassWithFields objectToSerialize = new SomeClassWithFields("a", "b"); + Gson gson = new Gson(); + String jsonRepresentation = gson.toJson(objectToSerialize); + System.out.println(jsonRepresentation); + + ===== OUTPUT ===== + {"name":"a","someOtherField":"b"} ++ +
NOTE: The value you specify in this annotation must be a valid JSON field name.
++ +
+
FieldNamingPolicy
+Required Element Summary | +|
---|---|
+ String |
+value
+
++ |
+
+Element Detail | +
---|
+public abstract String value+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: REQUIRED | OPTIONAL | ++DETAIL: ELEMENT | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: REQUIRED | OPTIONAL | ++DETAIL: ELEMENT | +
@Retention(value=RUNTIME) +@Target(value={FIELD,TYPE}) +public @interface Since
+An annotation that indicates the version number since a member or a type has been present. + This annotation is useful to manage versioning of your Json classes for a web-service. + +
+ This annotation has no effect unless you build Gson
with a
+ GsonBuilder
and invoke
+ GsonBuilder.setVersion(double)
method.
+
+
Here is an example of how this annotation is meant to be used:
++ public class User { + private String firstName; + private String lastName; + @Since(1.0) private String emailAddress; + @Since(1.0) private String password; + @Since(1.1) private Address address; + } ++ +
If you created Gson with new Gson()
, the toJson()
and fromJson()
+ methods will use all the fields for serialization and deserialization. However, if you created
+ Gson with Gson gson = new GsonBuilder().setVersion(1.0).create()
then the
+ toJson()
and fromJson()
methods of Gson will exclude the address
field
+ since it's version number is set to 1.1
.
+ +
+
+Required Element Summary | +|
---|---|
+ double |
+value
+
++ the value indicating a version number since this member + or type has been present. |
+
+Element Detail | +
---|
+public abstract double value+
+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: REQUIRED | OPTIONAL | ++DETAIL: ELEMENT | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: REQUIRED | OPTIONAL | ++DETAIL: ELEMENT | +
@Retention(value=RUNTIME) +@Target(value={FIELD,TYPE}) +public @interface Until
+An annotation that indicates the version number until a member or a type should be present.
+ Basically, if Gson is created with a version number that exceeds the value stored in the
+ Until
annotation then the field will be ignored from the JSON output. This annotation
+ is useful to manage versioning of your JSON classes for a web-service.
+
+
+ This annotation has no effect unless you build Gson
with a
+ GsonBuilder
and invoke
+ GsonBuilder.setVersion(double)
method.
+
+
Here is an example of how this annotation is meant to be used:
++ public class User { + private String firstName; + private String lastName; + @Until(1.1) private String emailAddress; + @Until(1.1) private String password; + } ++ +
If you created Gson with new Gson()
, the toJson()
and fromJson()
+ methods will use all the fields for serialization and deserialization. However, if you created
+ Gson with Gson gson = new GsonBuilder().setVersion(1.2).create()
then the
+ toJson()
and fromJson()
methods of Gson will exclude the emailAddress
+ and password
fields from the example above, because the version number passed to the
+ GsonBuilder, 1.2
, exceeds the version number set on the Until
annotation,
+ 1.1
, for those fields.
+
+ +
+
+Required Element Summary | +|
---|---|
+ double |
+value
+
++ the value indicating a version number until this member + or type should be ignored. |
+
+Element Detail | +
---|
+public abstract double value+
+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: REQUIRED | OPTIONAL | ++DETAIL: ELEMENT | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Annotation Types
+
+ +Expose + +SerializedName + +Since + +Until |
+
+
+
|
++ + | +|||||||||
+ PREV PACKAGE + NEXT PACKAGE | ++ FRAMES + NO FRAMES + + + + + | +
Gson
.
+
+See:
+
+ Description
+
+ +
+Annotation Types Summary | +|
---|---|
Expose | +An annotation that indicates this member should be exposed for JSON + serialization or deserialization. | +
SerializedName | +An annotation that indicates this member should be serialized to JSON with + the provided name value as its field name. | +
Since | +An annotation that indicates the version number since a member or a type has been present. | +
Until | +An annotation that indicates the version number until a member or a type should be present. | +
+This package provides annotations that can be used with Gson
.
+
+ +
+
+
+
|
++ + | +|||||||||
+ PREV PACKAGE + NEXT PACKAGE | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use ExclusionStrategy | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of ExclusionStrategy in com.google.gson | +
---|
+ +
Methods in com.google.gson with parameters of type ExclusionStrategy | +|
---|---|
+ GsonBuilder |
+GsonBuilder.addDeserializationExclusionStrategy(ExclusionStrategy strategy)
+
++ Configures Gson to apply the passed in exclusion strategy during deserialization. |
+
+ GsonBuilder |
+GsonBuilder.addSerializationExclusionStrategy(ExclusionStrategy strategy)
+
++ Configures Gson to apply the passed in exclusion strategy during serialization. |
+
+ GsonBuilder |
+GsonBuilder.setExclusionStrategies(ExclusionStrategy... strategies)
+
++ Configures Gson to apply a set of exclusion strategies during both serialization and + deserialization. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use FieldAttributes | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of FieldAttributes in com.google.gson | +
---|
+ +
Methods in com.google.gson with parameters of type FieldAttributes | +|
---|---|
+ boolean |
+ExclusionStrategy.shouldSkipField(FieldAttributes f)
+
++ |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use FieldNamingPolicy | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of FieldNamingPolicy in com.google.gson | +
---|
+ +
Methods in com.google.gson that return FieldNamingPolicy | +|
---|---|
+static FieldNamingPolicy |
+FieldNamingPolicy.valueOf(String name)
+
++ Returns the enum constant of this type with the specified name. |
+
+static FieldNamingPolicy[] |
+FieldNamingPolicy.values()
+
++ Returns an array containing the constants of this enum type, in +the order they are declared. |
+
+ +
Methods in com.google.gson with parameters of type FieldNamingPolicy | +|
---|---|
+ GsonBuilder |
+GsonBuilder.setFieldNamingPolicy(FieldNamingPolicy namingConvention)
+
++ Configures Gson to apply a specific naming policy to an object's field during serialization + and deserialization. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use FieldNamingStrategy | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of FieldNamingStrategy in com.google.gson | +
---|
+ +
Methods in com.google.gson with parameters of type FieldNamingStrategy | +|
---|---|
+ GsonBuilder |
+GsonBuilder.setFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy)
+
++ Configures Gson to apply a specific naming policy strategy to an object's field during + serialization and deserialization. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use Gson | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of Gson in com.google.gson | +
---|
+ +
Methods in com.google.gson that return Gson | +|
---|---|
+ Gson |
+GsonBuilder.create()
+
++ Creates a Gson instance based on the current configuration. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use GsonBuilder | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of GsonBuilder in com.google.gson | +
---|
+ +
Methods in com.google.gson that return GsonBuilder | +|
---|---|
+ GsonBuilder |
+GsonBuilder.addDeserializationExclusionStrategy(ExclusionStrategy strategy)
+
++ Configures Gson to apply the passed in exclusion strategy during deserialization. |
+
+ GsonBuilder |
+GsonBuilder.addSerializationExclusionStrategy(ExclusionStrategy strategy)
+
++ Configures Gson to apply the passed in exclusion strategy during serialization. |
+
+ GsonBuilder |
+GsonBuilder.disableHtmlEscaping()
+
++ By default, Gson escapes HTML characters such as < > etc. |
+
+ GsonBuilder |
+GsonBuilder.disableInnerClassSerialization()
+
++ Configures Gson to exclude inner classes during serialization. |
+
+ GsonBuilder |
+GsonBuilder.enableComplexMapKeySerialization()
+
++ Enabling this feature will only change the serialized form if the map key is + a complex type (i.e. |
+
+ GsonBuilder |
+GsonBuilder.excludeFieldsWithModifiers(int... modifiers)
+
++ Configures Gson to excludes all class fields that have the specified modifiers. |
+
+ GsonBuilder |
+GsonBuilder.excludeFieldsWithoutExposeAnnotation()
+
++ Configures Gson to exclude all fields from consideration for serialization or deserialization + that do not have the Expose annotation. |
+
+ GsonBuilder |
+GsonBuilder.generateNonExecutableJson()
+
++ Makes the output JSON non-executable in Javascript by prefixing the generated JSON with some + special text. |
+
+ GsonBuilder |
+GsonBuilder.registerTypeAdapter(Type type,
+ Object typeAdapter)
+
++ Configures Gson for custom serialization or deserialization. |
+
+ GsonBuilder |
+GsonBuilder.registerTypeHierarchyAdapter(Class<?> baseType,
+ Object typeAdapter)
+
++ Configures Gson for custom serialization or deserialization for an inheritance type hierarchy. |
+
+ GsonBuilder |
+GsonBuilder.serializeNulls()
+
++ Configure Gson to serialize null fields. |
+
+ GsonBuilder |
+GsonBuilder.serializeSpecialFloatingPointValues()
+
++ Section 2.4 of JSON specification disallows + special double values (NaN, Infinity, -Infinity). |
+
+ GsonBuilder |
+GsonBuilder.setDateFormat(int style)
+
++ Configures Gson to to serialize Date objects according to the style value provided. |
+
+ GsonBuilder |
+GsonBuilder.setDateFormat(int dateStyle,
+ int timeStyle)
+
++ Configures Gson to to serialize Date objects according to the style value provided. |
+
+ GsonBuilder |
+GsonBuilder.setDateFormat(String pattern)
+
++ Configures Gson to serialize Date objects according to the pattern provided. |
+
+ GsonBuilder |
+GsonBuilder.setExclusionStrategies(ExclusionStrategy... strategies)
+
++ Configures Gson to apply a set of exclusion strategies during both serialization and + deserialization. |
+
+ GsonBuilder |
+GsonBuilder.setFieldNamingPolicy(FieldNamingPolicy namingConvention)
+
++ Configures Gson to apply a specific naming policy to an object's field during serialization + and deserialization. |
+
+ GsonBuilder |
+GsonBuilder.setFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy)
+
++ Configures Gson to apply a specific naming policy strategy to an object's field during + serialization and deserialization. |
+
+ GsonBuilder |
+GsonBuilder.setLongSerializationPolicy(LongSerializationPolicy serializationPolicy)
+
++ Configures Gson to apply a specific serialization policy for Long and long
+ objects. |
+
+ GsonBuilder |
+GsonBuilder.setPrettyPrinting()
+
++ Configures Gson to output Json that fits in a page for pretty printing. |
+
+ GsonBuilder |
+GsonBuilder.setVersion(double ignoreVersionsAfter)
+
++ Configures Gson to enable versioning support. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use JsonArray | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of JsonArray in com.google.gson | +
---|
+ +
Methods in com.google.gson that return JsonArray | +|
---|---|
+ JsonArray |
+JsonElement.getAsJsonArray()
+
++ convenience method to get this element as a JsonArray . |
+
+ JsonArray |
+JsonObject.getAsJsonArray(String memberName)
+
++ Convenience method to get the specified member as a JsonArray. |
+
+ +
Methods in com.google.gson with parameters of type JsonArray | +|
---|---|
+ void |
+JsonArray.addAll(JsonArray array)
+
++ Adds all the elements of the specified array to self. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use JsonDeserializationContext | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of JsonDeserializationContext in com.google.gson | +
---|
+ +
Methods in com.google.gson with parameters of type JsonDeserializationContext | +|
---|---|
+ T |
+JsonDeserializer.deserialize(JsonElement json,
+ Type typeOfT,
+ JsonDeserializationContext context)
+
++ Gson invokes this call-back method during deserialization when it encounters a field of the + specified type. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use JsonElement | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of JsonElement in com.google.gson | +
---|
+ +
Subclasses of JsonElement in com.google.gson | +|
---|---|
+ class |
+JsonArray
+
++ A class representing an array type in Json. |
+
+ class |
+JsonNull
+
++ A class representing a Json null value. |
+
+ class |
+JsonObject
+
++ A class representing an object type in Json. |
+
+ class |
+JsonPrimitive
+
++ A class representing a Json primitive value. |
+
+ +
Methods in com.google.gson that return JsonElement | +|
---|---|
+ JsonElement |
+JsonArray.get(int i)
+
++ Returns the ith element of the array. |
+
+ JsonElement |
+JsonObject.get(String memberName)
+
++ Returns the member with the specified name. |
+
+ JsonElement |
+JsonStreamParser.next()
+
++ Returns the next available JsonElement on the reader. |
+
+ JsonElement |
+JsonParser.parse(JsonReader json)
+
++ Returns the next value from the JSON stream as a parse tree. |
+
+ JsonElement |
+JsonParser.parse(Reader json)
+
++ Parses the specified JSON string into a parse tree |
+
+ JsonElement |
+JsonParser.parse(String json)
+
++ Parses the specified JSON string into a parse tree |
+
+ JsonElement |
+JsonObject.remove(String property)
+
++ Removes the property from this JsonObject . |
+
+ JsonElement |
+LongSerializationPolicy.serialize(Long value)
+
++ Serialize this value using this serialization policy. |
+
+ JsonElement |
+JsonSerializationContext.serialize(Object src)
+
++ Invokes default serialization on the specified object. |
+
+ JsonElement |
+JsonSerializationContext.serialize(Object src,
+ Type typeOfSrc)
+
++ Invokes default serialization on the specified object passing the specific type information. |
+
+ JsonElement |
+JsonSerializer.serialize(T src,
+ Type typeOfSrc,
+ JsonSerializationContext context)
+
++ Gson invokes this call-back method during serialization when it encounters a field of the + specified type. |
+
+ JsonElement |
+Gson.toJsonTree(Object src)
+
++ This method serializes the specified object into its equivalent representation as a tree of + JsonElement s. |
+
+ JsonElement |
+Gson.toJsonTree(Object src,
+ Type typeOfSrc)
+
++ This method serializes the specified object, including those of generic types, into its + equivalent representation as a tree of JsonElement s. |
+
+ +
Methods in com.google.gson that return types with arguments of type JsonElement | +|
---|---|
+ Set<Map.Entry<String,JsonElement>> |
+JsonObject.entrySet()
+
++ Returns a set of members of this object. |
+
+ Iterator<JsonElement> |
+JsonArray.iterator()
+
++ Returns an iterator to navigate the elemetns of the array. |
+
+ +
Methods in com.google.gson with parameters of type JsonElement | +||
---|---|---|
+ void |
+JsonArray.add(JsonElement element)
+
++ Adds the specified element to self. |
+|
+ void |
+JsonObject.add(String property,
+ JsonElement value)
+
++ Adds a member, which is a name-value pair, to self. |
+|
+
+ |
+JsonDeserializationContext.deserialize(JsonElement json,
+ Type typeOfT)
+
++ Invokes default deserialization on the specified object. |
+|
+ T |
+JsonDeserializer.deserialize(JsonElement json,
+ Type typeOfT,
+ JsonDeserializationContext context)
+
++ Gson invokes this call-back method during deserialization when it encounters a field of the + specified type. |
+|
+
+ |
+Gson.fromJson(JsonElement json,
+ Class<T> classOfT)
+
++ This method deserializes the Json read from the specified parse tree into an object of the + specified type. |
+|
+
+ |
+Gson.fromJson(JsonElement json,
+ Type typeOfT)
+
++ This method deserializes the Json read from the specified parse tree into an object of the + specified type. |
+|
+ String |
+Gson.toJson(JsonElement jsonElement)
+
++ Converts a tree of JsonElement s into its equivalent JSON representation. |
+|
+ void |
+Gson.toJson(JsonElement jsonElement,
+ Appendable writer)
+
++ Writes out the equivalent JSON for a tree of JsonElement s. |
+|
+ void |
+Gson.toJson(JsonElement jsonElement,
+ JsonWriter writer)
+
++ Writes the JSON for jsonElement to writer . |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use JsonIOException | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of JsonIOException in com.google.gson | +
---|
+ +
Methods in com.google.gson that throw JsonIOException | +||
---|---|---|
+
+ |
+Gson.fromJson(JsonReader reader,
+ Type typeOfT)
+
++ Reads the next JSON value from reader and convert it to an object
+ of type typeOfT . |
+|
+
+ |
+Gson.fromJson(Reader json,
+ Class<T> classOfT)
+
++ This method deserializes the Json read from the specified reader into an object of the + specified class. |
+|
+
+ |
+Gson.fromJson(Reader json,
+ Type typeOfT)
+
++ This method deserializes the Json read from the specified reader into an object of the + specified type. |
+|
+ JsonElement |
+JsonParser.parse(JsonReader json)
+
++ Returns the next value from the JSON stream as a parse tree. |
+|
+ JsonElement |
+JsonParser.parse(Reader json)
+
++ Parses the specified JSON string into a parse tree |
+|
+ void |
+Gson.toJson(JsonElement jsonElement,
+ Appendable writer)
+
++ Writes out the equivalent JSON for a tree of JsonElement s. |
+|
+ void |
+Gson.toJson(JsonElement jsonElement,
+ JsonWriter writer)
+
++ Writes the JSON for jsonElement to writer . |
+|
+ void |
+Gson.toJson(Object src,
+ Appendable writer)
+
++ This method serializes the specified object into its equivalent Json representation. |
+|
+ void |
+Gson.toJson(Object src,
+ Type typeOfSrc,
+ Appendable writer)
+
++ This method serializes the specified object, including those of generic types, into its + equivalent Json representation. |
+|
+ void |
+Gson.toJson(Object src,
+ Type typeOfSrc,
+ JsonWriter writer)
+
++ Writes the JSON representation of src of type typeOfSrc to
+ writer . |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use JsonNull | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of JsonNull in com.google.gson | +
---|
+ +
Fields in com.google.gson declared as JsonNull | +|
---|---|
+static JsonNull |
+JsonNull.INSTANCE
+
++ singleton for JsonNull |
+
+ +
Methods in com.google.gson that return JsonNull | +|
---|---|
+ JsonNull |
+JsonElement.getAsJsonNull()
+
++ convenience method to get this element as a JsonNull . |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use JsonObject | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of JsonObject in com.google.gson | +
---|
+ +
Methods in com.google.gson that return JsonObject | +|
---|---|
+ JsonObject |
+JsonElement.getAsJsonObject()
+
++ convenience method to get this element as a JsonObject . |
+
+ JsonObject |
+JsonObject.getAsJsonObject(String memberName)
+
++ Convenience method to get the specified member as a JsonObject. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use JsonParseException | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of JsonParseException in com.google.gson | +
---|
+ +
Subclasses of JsonParseException in com.google.gson | +|
---|---|
+ class |
+JsonIOException
+
++ This exception is raised when Gson was unable to read an input stream + or write to one. |
+
+ class |
+JsonSyntaxException
+
++ This exception is raised when Gson attempts to read (or write) a malformed + JSON element. |
+
+ +
Methods in com.google.gson that throw JsonParseException | +||
---|---|---|
+
+ |
+JsonDeserializationContext.deserialize(JsonElement json,
+ Type typeOfT)
+
++ Invokes default deserialization on the specified object. |
+|
+ T |
+JsonDeserializer.deserialize(JsonElement json,
+ Type typeOfT,
+ JsonDeserializationContext context)
+
++ Gson invokes this call-back method during deserialization when it encounters a field of the + specified type. |
+|
+ JsonElement |
+JsonStreamParser.next()
+
++ Returns the next available JsonElement on the reader. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use JsonPrimitive | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of JsonPrimitive in com.google.gson | +
---|
+ +
Methods in com.google.gson that return JsonPrimitive | +|
---|---|
+ JsonPrimitive |
+JsonElement.getAsJsonPrimitive()
+
++ convenience method to get this element as a JsonPrimitive . |
+
+ JsonPrimitive |
+JsonObject.getAsJsonPrimitive(String memberName)
+
++ Convenience method to get the specified member as a JsonPrimitive element. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use JsonSerializationContext | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of JsonSerializationContext in com.google.gson | +
---|
+ +
Methods in com.google.gson with parameters of type JsonSerializationContext | +|
---|---|
+ JsonElement |
+JsonSerializer.serialize(T src,
+ Type typeOfSrc,
+ JsonSerializationContext context)
+
++ Gson invokes this call-back method during serialization when it encounters a field of the + specified type. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use JsonSyntaxException | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of JsonSyntaxException in com.google.gson | +
---|
+ +
Methods in com.google.gson that throw JsonSyntaxException | +||
---|---|---|
+
+ |
+Gson.fromJson(JsonElement json,
+ Class<T> classOfT)
+
++ This method deserializes the Json read from the specified parse tree into an object of the + specified type. |
+|
+
+ |
+Gson.fromJson(JsonElement json,
+ Type typeOfT)
+
++ This method deserializes the Json read from the specified parse tree into an object of the + specified type. |
+|
+
+ |
+Gson.fromJson(JsonReader reader,
+ Type typeOfT)
+
++ Reads the next JSON value from reader and convert it to an object
+ of type typeOfT . |
+|
+
+ |
+Gson.fromJson(Reader json,
+ Class<T> classOfT)
+
++ This method deserializes the Json read from the specified reader into an object of the + specified class. |
+|
+
+ |
+Gson.fromJson(Reader json,
+ Type typeOfT)
+
++ This method deserializes the Json read from the specified reader into an object of the + specified type. |
+|
+
+ |
+Gson.fromJson(String json,
+ Class<T> classOfT)
+
++ This method deserializes the specified Json into an object of the specified class. |
+|
+
+ |
+Gson.fromJson(String json,
+ Type typeOfT)
+
++ This method deserializes the specified Json into an object of the specified type. |
+|
+ JsonElement |
+JsonParser.parse(JsonReader json)
+
++ Returns the next value from the JSON stream as a parse tree. |
+|
+ JsonElement |
+JsonParser.parse(Reader json)
+
++ Parses the specified JSON string into a parse tree |
+|
+ JsonElement |
+JsonParser.parse(String json)
+
++ Parses the specified JSON string into a parse tree |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use LongSerializationPolicy | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of LongSerializationPolicy in com.google.gson | +
---|
+ +
Methods in com.google.gson that return LongSerializationPolicy | +|
---|---|
+static LongSerializationPolicy |
+LongSerializationPolicy.valueOf(String name)
+
++ Returns the enum constant of this type with the specified name. |
+
+static LongSerializationPolicy[] |
+LongSerializationPolicy.values()
+
++ Returns an array containing the constants of this enum type, in +the order they are declared. |
+
+ +
Methods in com.google.gson with parameters of type LongSerializationPolicy | +|
---|---|
+ GsonBuilder |
+GsonBuilder.setLongSerializationPolicy(LongSerializationPolicy serializationPolicy)
+
++ Configures Gson to apply a specific serialization policy for Long and long
+ objects. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.$Gson$Preconditions ++
public final class $Gson$Preconditions
+A simple utility class used to check method Preconditions. + +
+ public long divideBy(long value) { + Preconditions.checkArgument(value != 0); + return this.value / value; + } ++
+ +
+
+Constructor Summary | +|
---|---|
$Gson$Preconditions()
+
++ |
+
+Method Summary | +||
---|---|---|
+static void |
+checkArgument(boolean condition)
+
++ |
+|
+static
+ |
+checkNotNull(T obj)
+
++ |
+|
+static void |
+checkState(boolean condition)
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public $Gson$Preconditions()+
+Method Detail | +
---|
+public static <T> T checkNotNull(T obj)+
+public static void checkArgument(boolean condition)+
+public static void checkState(boolean condition)+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.$Gson$Types ++
public final class $Gson$Types
+Static methods for working with types. +
+ +
+
+Method Summary | +|
---|---|
+static GenericArrayType |
+arrayOf(Type componentType)
+
++ Returns an array type whose elements are all instances of + componentType . |
+
+static Type |
+canonicalize(Type type)
+
++ Returns a type that is functionally equal but not necessarily equal + according to Object.equals() . |
+
+static boolean |
+equals(Type a,
+ Type b)
+
++ Returns true if a and b are equal. |
+
+static Type |
+getArrayComponentType(Type array)
+
++ Returns the component type of this array type. |
+
+static Type |
+getCollectionElementType(Type context,
+ Class<?> contextRawType)
+
++ Returns the element type of this collection type. |
+
+static Type[] |
+getMapKeyAndValueTypes(Type context,
+ Class<?> contextRawType)
+
++ Returns a two element array containing this map's key and value types in + positions 0 and 1 respectively. |
+
+static Class<?> |
+getRawType(Type type)
+
++ |
+
+static boolean |
+isArray(Type type)
+
++ Returns true if this type is an array. |
+
+static ParameterizedType |
+newParameterizedTypeWithOwner(Type ownerType,
+ Type rawType,
+ Type... typeArguments)
+
++ Returns a new parameterized type, applying typeArguments to
+ rawType and enclosed by ownerType . |
+
+static Type |
+resolve(Type context,
+ Class<?> contextRawType,
+ Type toResolve)
+
++ |
+
+static WildcardType |
+subtypeOf(Type bound)
+
++ Returns a type that represents an unknown type that extends bound . |
+
+static WildcardType |
+supertypeOf(Type bound)
+
++ Returns a type that represents an unknown supertype of bound . |
+
+static String |
+typeToString(Type type)
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Method Detail | +
---|
+public static ParameterizedType newParameterizedTypeWithOwner(Type ownerType, + Type rawType, + Type... typeArguments)+
typeArguments
to
+ rawType
and enclosed by ownerType
.
++
serializable
parameterized type.+public static GenericArrayType arrayOf(Type componentType)+
componentType
.
++
serializable
generic array type.+public static WildcardType subtypeOf(Type bound)+
bound
.
+ For example, if bound
is CharSequence.class
, this returns
+ ? extends CharSequence
. If bound
is Object.class
,
+ this returns ?
, which is shorthand for ? extends Object
.
++
+public static WildcardType supertypeOf(Type bound)+
bound
. For
+ example, if bound
is String.class
, this returns ?
+ super String
.
++
+public static Type canonicalize(Type type)+
Object.equals()
. The returned
+ type is Serializable
.
++
+public static Class<?> getRawType(Type type)+
+public static boolean equals(Type a, + Type b)+
a
and b
are equal.
++
+public static String typeToString(Type type)+
+public static boolean isArray(Type type)+
+
+public static Type getArrayComponentType(Type array)+
+
ClassCastException
- if this type is not an array.+public static Type getCollectionElementType(Type context, + Class<?> contextRawType)+
+
IllegalArgumentException
- if this type is not a collection.+public static Type[] getMapKeyAndValueTypes(Type context, + Class<?> contextRawType)+
+
+public static Type resolve(Type context, + Class<?> contextRawType, + Type toResolve)+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.ConstructorConstructor ++
public final class ConstructorConstructor
+Returns a function that can construct an instance of a requested type. +
+ +
+
+Constructor Summary | +|
---|---|
ConstructorConstructor()
+
++ |
+|
ConstructorConstructor(ParameterizedTypeHandlerMap<InstanceCreator<?>> instanceCreators)
+
++ |
+
+Method Summary | +||
---|---|---|
+
+ |
+getConstructor(TypeToken<T> typeToken)
+
++ |
+|
+ String |
+toString()
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public ConstructorConstructor(ParameterizedTypeHandlerMap<InstanceCreator<?>> instanceCreators)+
+public ConstructorConstructor()+
+Method Detail | +
---|
+public <T> ObjectConstructor<T> getConstructor(TypeToken<T> typeToken)+
+public String toString()+
toString
in class Object
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + java.lang.Number + com.google.gson.internal.LazilyParsedNumber ++
public final class LazilyParsedNumber
+This class holds a number value that is lazily converted to a specific number type +
+ +
+
+Constructor Summary | +|
---|---|
LazilyParsedNumber(String value)
+
++ |
+
+Method Summary | +|
---|---|
+ double |
+doubleValue()
+
++ |
+
+ float |
+floatValue()
+
++ |
+
+ int |
+intValue()
+
++ |
+
+ long |
+longValue()
+
++ |
+
+ String |
+toString()
+
++ |
+
Methods inherited from class java.lang.Number | +
---|
byteValue, shortValue |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public LazilyParsedNumber(String value)+
+Method Detail | +
---|
+public int intValue()+
intValue
in class Number
+public long longValue()+
longValue
in class Number
+public float floatValue()+
floatValue
in class Number
+public double doubleValue()+
doubleValue
in class Number
+public String toString()+
toString
in class Object
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
public interface ObjectConstructor<T>
+Defines a generic object construction factory. The purpose of this class + is to construct a default instance of a class that can be used for object + navigation while deserialization from its JSON representation. +
+ +
+
+Method Summary | +|
---|---|
+ T |
+construct()
+
++ Returns a new instance. |
+
+Method Detail | +
---|
+T construct()+
+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.Pair<FIRST,SECOND> ++
FIRST
- SECOND
- public final class Pair<FIRST,SECOND>
+A simple object that holds onto a pair of object references, first and second. +
+ +
+
+Field Summary | +|
---|---|
+ FIRST |
+first
+
++ |
+
+ SECOND |
+second
+
++ |
+
+Constructor Summary | +|
---|---|
Pair(FIRST first,
+ SECOND second)
+
++ |
+
+Method Summary | +|
---|---|
+ boolean |
+equals(Object o)
+
++ |
+
+ int |
+hashCode()
+
++ |
+
+ String |
+toString()
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
getClass, notify, notifyAll, wait, wait, wait |
+
+Field Detail | +
---|
+public final FIRST first+
+public final SECOND second+
+Constructor Detail | +
---|
+public Pair(FIRST first, + SECOND second)+
+Method Detail | +
---|
+public int hashCode()+
hashCode
in class Object
+public boolean equals(Object o)+
equals
in class Object
+public String toString()+
toString
in class Object
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.ParameterizedTypeHandlerMap<T> ++
T
- The handler that will be looked up by typepublic final class ParameterizedTypeHandlerMap<T>
+A map that provides ability to associate handlers for a specific type or all + of its sub-types +
+ +
+
+Constructor Summary | +|
---|---|
ParameterizedTypeHandlerMap()
+
++ |
+
+Method Summary | +|
---|---|
+ ParameterizedTypeHandlerMap<T> |
+copyOf()
+
++ |
+
+ T |
+getHandlerFor(Type type,
+ boolean systemOnly)
+
++ |
+
+ boolean |
+hasSpecificHandlerFor(Type type)
+
++ |
+
+ ParameterizedTypeHandlerMap<T> |
+makeUnmodifiable()
+
++ |
+
+ void |
+register(Type typeOfT,
+ T value,
+ boolean isSystem)
+
++ |
+
+ void |
+registerForTypeHierarchy(Class<?> typeOfT,
+ T value,
+ boolean isSystem)
+
++ |
+
+ void |
+registerForTypeHierarchy(Pair<Class<?>,T> pair,
+ boolean isSystem)
+
++ |
+
+ void |
+registerIfAbsent(ParameterizedTypeHandlerMap<T> other)
+
++ |
+
+ String |
+toString()
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public ParameterizedTypeHandlerMap()+
+Method Detail | +
---|
+public void registerForTypeHierarchy(Class<?> typeOfT, + T value, + boolean isSystem)+
+public void registerForTypeHierarchy(Pair<Class<?>,T> pair, + boolean isSystem)+
+public void register(Type typeOfT, + T value, + boolean isSystem)+
+public void registerIfAbsent(ParameterizedTypeHandlerMap<T> other)+
+public ParameterizedTypeHandlerMap<T> makeUnmodifiable()+
+public T getHandlerFor(Type type, + boolean systemOnly)+
+public boolean hasSpecificHandlerFor(Type type)+
+public ParameterizedTypeHandlerMap<T> copyOf()+
+public String toString()+
toString
in class Object
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.Primitives ++
public final class Primitives
+Contains static utility methods pertaining to primitive types and their + corresponding wrapper types. +
+ +
+
+Method Summary | +||
---|---|---|
+static boolean |
+isPrimitive(Type type)
+
++ Returns true if this type is a primitive. |
+|
+static boolean |
+isWrapperType(Type type)
+
++ Returns true if type is one of the nine
+ primitive-wrapper types, such as Integer . |
+|
+static
+ |
+unwrap(Class<T> type)
+
++ Returns the corresponding primitive type of type if it is a
+ wrapper type; otherwise returns type itself. |
+|
+static
+ |
+wrap(Class<T> type)
+
++ Returns the corresponding wrapper type of type if it is a primitive
+ type; otherwise returns type itself. |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Method Detail | +
---|
+public static boolean isPrimitive(Type type)+
+
+public static boolean isWrapperType(Type type)+
true
if type
is one of the nine
+ primitive-wrapper types, such as Integer
.
++
Class.isPrimitive()
+public static <T> Class<T> wrap(Class<T> type)+
type
if it is a primitive
+ type; otherwise returns type
itself. Idempotent.
+ + wrap(int.class) == Integer.class + wrap(Integer.class) == Integer.class + wrap(String.class) == String.class ++
+
+public static <T> Class<T> unwrap(Class<T> type)+
type
if it is a
+ wrapper type; otherwise returns type
itself. Idempotent.
+ + unwrap(Integer.class) == int.class + unwrap(int.class) == int.class + unwrap(String.class) == String.class ++
+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.Streams ++
public final class Streams
+Reads and writes GSON parse trees over streams. +
+ +
+
+Constructor Summary | +|
---|---|
Streams()
+
++ |
+
+Method Summary | +|
---|---|
+static JsonElement |
+parse(JsonReader reader)
+
++ Takes a reader in any state and returns the next value as a JsonElement. |
+
+static void |
+write(JsonElement element,
+ JsonWriter writer)
+
++ Writes the JSON element to the writer, recursively. |
+
+static Writer |
+writerForAppendable(Appendable appendable)
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public Streams()+
+Method Detail | +
---|
+public static JsonElement parse(JsonReader reader) + throws JsonParseException+
+
JsonParseException
+public static void write(JsonElement element, + JsonWriter writer) + throws IOException+
+
IOException
+public static Writer writerForAppendable(Appendable appendable)+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.UnsafeAllocator ++
public abstract class UnsafeAllocator
+Do sneaky things to allocate objects without invoking their constructors. +
+ +
+
+Constructor Summary | +|
---|---|
UnsafeAllocator()
+
++ |
+
+Method Summary | +||
---|---|---|
+static UnsafeAllocator |
+create()
+
++ |
+|
+abstract
+ |
+newInstance(Class<T> c)
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public UnsafeAllocator()+
+Method Detail | +
---|
+public abstract <T> T newInstance(Class<T> c) + throws Exception+
Exception
+public static UnsafeAllocator create()+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.TypeAdapter<Object> + com.google.gson.internal.bind.ArrayTypeAdapter<E> ++
public final class ArrayTypeAdapter<E>
+Adapt an array of objects. +
+ +
+
+Nested Class Summary | +
---|
Nested classes/interfaces inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
TypeAdapter.Factory |
+
+Field Summary | +|
---|---|
+static TypeAdapter.Factory |
+FACTORY
+
++ |
+
+Constructor Summary | +|
---|---|
ArrayTypeAdapter(MiniGson context,
+ TypeAdapter<E> componentTypeAdapter,
+ Class<E> componentType)
+
++ |
+
+Method Summary | +|
---|---|
+ Object |
+read(JsonReader reader)
+
++ |
+
+ void |
+write(JsonWriter writer,
+ Object array)
+
++ |
+
Methods inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
fromJson, fromJsonElement, read, toJson, toJsonElement, write |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Field Detail | +
---|
+public static final TypeAdapter.Factory FACTORY+
+Constructor Detail | +
---|
+public ArrayTypeAdapter(MiniGson context, + TypeAdapter<E> componentTypeAdapter, + Class<E> componentType)+
+Method Detail | +
---|
+public Object read(JsonReader reader) + throws IOException+
read
in class TypeAdapter<Object>
IOException
+public void write(JsonWriter writer, + Object array) + throws IOException+
write
in class TypeAdapter<Object>
IOException
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.TypeAdapter<BigDecimal> + com.google.gson.internal.bind.BigDecimalTypeAdapter ++
public final class BigDecimalTypeAdapter
+Adapts a BigDecimal type to and from its JSON representation. +
+ +
+
+Nested Class Summary | +
---|
Nested classes/interfaces inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
TypeAdapter.Factory |
+
+Constructor Summary | +|
---|---|
BigDecimalTypeAdapter()
+
++ |
+
+Method Summary | +|
---|---|
+ BigDecimal |
+read(JsonReader reader)
+
++ |
+
+ void |
+write(JsonWriter writer,
+ BigDecimal value)
+
++ |
+
Methods inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
fromJson, fromJsonElement, read, toJson, toJsonElement, write |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public BigDecimalTypeAdapter()+
+Method Detail | +
---|
+public BigDecimal read(JsonReader reader) + throws IOException+
read
in class TypeAdapter<BigDecimal>
IOException
+public void write(JsonWriter writer, + BigDecimal value) + throws IOException+
write
in class TypeAdapter<BigDecimal>
IOException
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.TypeAdapter<BigInteger> + com.google.gson.internal.bind.BigIntegerTypeAdapter ++
public final class BigIntegerTypeAdapter
+Adapts a BigInteger type to and from its JSON representation. +
+ +
+
+Nested Class Summary | +
---|
Nested classes/interfaces inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
TypeAdapter.Factory |
+
+Constructor Summary | +|
---|---|
BigIntegerTypeAdapter()
+
++ |
+
+Method Summary | +|
---|---|
+ BigInteger |
+read(JsonReader reader)
+
++ |
+
+ void |
+write(JsonWriter writer,
+ BigInteger value)
+
++ |
+
Methods inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
fromJson, fromJsonElement, read, toJson, toJsonElement, write |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public BigIntegerTypeAdapter()+
+Method Detail | +
---|
+public BigInteger read(JsonReader reader) + throws IOException+
read
in class TypeAdapter<BigInteger>
IOException
+public void write(JsonWriter writer, + BigInteger value) + throws IOException+
write
in class TypeAdapter<BigInteger>
IOException
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.CollectionTypeAdapterFactory ++
public final class CollectionTypeAdapterFactory
+Adapt a homogeneous collection of objects. +
+ +
+
+Constructor Summary | +|
---|---|
CollectionTypeAdapterFactory(ConstructorConstructor constructorConstructor)
+
++ |
+
+Method Summary | +||
---|---|---|
+
+ |
+create(MiniGson context,
+ TypeToken<T> typeToken)
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public CollectionTypeAdapterFactory(ConstructorConstructor constructorConstructor)+
+Method Detail | +
---|
+public <T> TypeAdapter<T> create(MiniGson context, + TypeToken<T> typeToken)+
create
in interface TypeAdapter.Factory
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.TypeAdapter<Date> + com.google.gson.internal.bind.DateTypeAdapter ++
public final class DateTypeAdapter
+Adapter for Date. Although this class appears stateless, it is not. + DateFormat captures its time zone and locale when it is created, which gives + this class state. DateFormat isn't thread safe either, so this class has + to synchronize its read and write methods. +
+ +
+
+Nested Class Summary | +
---|
Nested classes/interfaces inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
TypeAdapter.Factory |
+
+Field Summary | +|
---|---|
+static TypeAdapter.Factory |
+FACTORY
+
++ |
+
+Constructor Summary | +|
---|---|
DateTypeAdapter()
+
++ |
+
+Method Summary | +|
---|---|
+ Date |
+read(JsonReader reader)
+
++ |
+
+ void |
+write(JsonWriter writer,
+ Date value)
+
++ |
+
Methods inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
fromJson, fromJsonElement, read, toJson, toJsonElement, write |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Field Detail | +
---|
+public static final TypeAdapter.Factory FACTORY+
+Constructor Detail | +
---|
+public DateTypeAdapter()+
+Method Detail | +
---|
+public Date read(JsonReader reader) + throws IOException+
read
in class TypeAdapter<Date>
IOException
+public void write(JsonWriter writer, + Date value) + throws IOException+
write
in class TypeAdapter<Date>
IOException
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.ExcludedTypeAdapterFactory ++
public final class ExcludedTypeAdapterFactory
+This type adapter skips values using an exclusion strategy. It may delegate + to another type adapter if only one direction is excluded. +
+ +
+
+Constructor Summary | +|
---|---|
ExcludedTypeAdapterFactory(ExclusionStrategy serializationExclusionStrategy,
+ ExclusionStrategy deserializationExclusionStrategy)
+
++ |
+
+Method Summary | +||
---|---|---|
+
+ |
+create(MiniGson context,
+ TypeToken<T> type)
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public ExcludedTypeAdapterFactory(ExclusionStrategy serializationExclusionStrategy, + ExclusionStrategy deserializationExclusionStrategy)+
+Method Detail | +
---|
+public <T> TypeAdapter<T> create(MiniGson context, + TypeToken<T> type)+
create
in interface TypeAdapter.Factory
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.stream.JsonReader + com.google.gson.internal.bind.JsonElementReader ++
public final class JsonElementReader
+This reader walks the elements of a JsonElement as if it was coming from a + character stream. +
+ +
+
+Constructor Summary | +|
---|---|
JsonElementReader(JsonElement element)
+
++ |
+
+Method Summary | +|
---|---|
+ void |
+beginArray()
+
++ Consumes the next token from the JSON stream and asserts that it is the + beginning of a new array. |
+
+ void |
+beginObject()
+
++ Consumes the next token from the JSON stream and asserts that it is the + beginning of a new object. |
+
+ void |
+close()
+
++ Closes this JSON reader and the underlying Reader . |
+
+ void |
+endArray()
+
++ Consumes the next token from the JSON stream and asserts that it is the + end of the current array. |
+
+ void |
+endObject()
+
++ Consumes the next token from the JSON stream and asserts that it is the + end of the current array. |
+
+ boolean |
+hasNext()
+
++ Returns true if the current array or object has another element. |
+
+ boolean |
+nextBoolean()
+
++ Returns the boolean value of the next token,
+ consuming it. |
+
+ double |
+nextDouble()
+
++ Returns the double value of the next token,
+ consuming it. |
+
+ int |
+nextInt()
+
++ Returns the int value of the next token,
+ consuming it. |
+
+ long |
+nextLong()
+
++ Returns the long value of the next token,
+ consuming it. |
+
+ String |
+nextName()
+
++ Returns the next token, a property name , and
+ consumes it. |
+
+ void |
+nextNull()
+
++ Consumes the next token from the JSON stream and asserts that it is a + literal null. |
+
+ String |
+nextString()
+
++ Returns the string value of the next token,
+ consuming it. |
+
+ JsonToken |
+peek()
+
++ Returns the type of the next token without consuming it. |
+
+ void |
+skipValue()
+
++ Skips the next value recursively. |
+
+ String |
+toString()
+
++ |
+
Methods inherited from class com.google.gson.stream.JsonReader | +
---|
isLenient, setLenient |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public JsonElementReader(JsonElement element)+
+Method Detail | +
---|
+public void beginArray() + throws IOException+
JsonReader
+
beginArray
in class JsonReader
IOException
+public void endArray() + throws IOException+
JsonReader
+
endArray
in class JsonReader
IOException
+public void beginObject() + throws IOException+
JsonReader
+
beginObject
in class JsonReader
IOException
+public void endObject() + throws IOException+
JsonReader
+
endObject
in class JsonReader
IOException
+public boolean hasNext() + throws IOException+
JsonReader
+
hasNext
in class JsonReader
IOException
+public JsonToken peek() + throws IOException+
JsonReader
+
peek
in class JsonReader
IOException
+public String nextName() + throws IOException+
JsonReader
property name
, and
+ consumes it.
++
nextName
in class JsonReader
IOException
- if the next token in the stream is not a property
+ name.+public String nextString() + throws IOException+
JsonReader
string
value of the next token,
+ consuming it. If the next token is a number, this method will return its
+ string form.
++
nextString
in class JsonReader
IOException
+public boolean nextBoolean() + throws IOException+
JsonReader
boolean
value of the next token,
+ consuming it.
++
nextBoolean
in class JsonReader
IOException
+public void nextNull() + throws IOException+
JsonReader
+
nextNull
in class JsonReader
IOException
+public double nextDouble() + throws IOException+
JsonReader
double
value of the next token,
+ consuming it. If the next token is a string, this method will attempt to
+ parse it as a double.
++
nextDouble
in class JsonReader
IOException
+public long nextLong() + throws IOException+
JsonReader
long
value of the next token,
+ consuming it. If the next token is a string, this method will attempt to
+ parse it as a long. If the next token's numeric value cannot be exactly
+ represented by a Java long
, this method throws.
++
nextLong
in class JsonReader
IOException
+public int nextInt() + throws IOException+
JsonReader
int
value of the next token,
+ consuming it. If the next token is a string, this method will attempt to
+ parse it as an int. If the next token's numeric value cannot be exactly
+ represented by a Java int
, this method throws.
++
nextInt
in class JsonReader
IOException
+public void close() + throws IOException+
JsonReader
Reader
.
++
close
in interface Closeable
close
in class JsonReader
IOException
+public void skipValue() + throws IOException+
JsonReader
+
skipValue
in class JsonReader
IOException
+public String toString()+
toString
in class JsonReader
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.stream.JsonWriter + com.google.gson.internal.bind.JsonElementWriter ++
public final class JsonElementWriter
+This writer creates a JsonElement. +
+ +
+
+Constructor Summary | +|
---|---|
JsonElementWriter()
+
++ |
+
+Method Summary | +|
---|---|
+ JsonWriter |
+beginArray()
+
++ Begins encoding a new array. |
+
+ JsonWriter |
+beginObject()
+
++ Begins encoding a new object. |
+
+ void |
+close()
+
++ Flushes and closes this writer and the underlying Writer . |
+
+ JsonWriter |
+endArray()
+
++ Ends encoding the current array. |
+
+ JsonWriter |
+endObject()
+
++ Ends encoding the current object. |
+
+ void |
+flush()
+
++ Ensures all buffered data is written to the underlying Writer
+ and flushes that writer. |
+
+ JsonElement |
+get()
+
++ Returns the top level object produced by this writer. |
+
+ JsonWriter |
+name(String name)
+
++ Encodes the property name. |
+
+ JsonWriter |
+nullValue()
+
++ Encodes null . |
+
+ JsonWriter |
+value(boolean value)
+
++ Encodes value . |
+
+ JsonWriter |
+value(double value)
+
++ Encodes value . |
+
+ JsonWriter |
+value(long value)
+
++ Encodes value . |
+
+ JsonWriter |
+value(Number value)
+
++ Encodes value . |
+
+ JsonWriter |
+value(String value)
+
++ Encodes value . |
+
Methods inherited from class com.google.gson.stream.JsonWriter | +
---|
getSerializeNulls, isHtmlSafe, isLenient, setHtmlSafe, setIndent, setLenient, setSerializeNulls |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public JsonElementWriter()+
+Method Detail | +
---|
+public JsonElement get()+
+
+public JsonWriter beginArray() + throws IOException+
JsonWriter
JsonWriter.endArray()
.
++
beginArray
in class JsonWriter
IOException
+public JsonWriter endArray() + throws IOException+
JsonWriter
+
endArray
in class JsonWriter
IOException
+public JsonWriter beginObject() + throws IOException+
JsonWriter
JsonWriter.endObject()
.
++
beginObject
in class JsonWriter
IOException
+public JsonWriter endObject() + throws IOException+
JsonWriter
+
endObject
in class JsonWriter
IOException
+public JsonWriter name(String name) + throws IOException+
JsonWriter
+
name
in class JsonWriter
name
- the name of the forthcoming value. May not be null.
+IOException
+public JsonWriter value(String value) + throws IOException+
JsonWriter
value
.
++
value
in class JsonWriter
value
- the literal string value, or null to encode a null literal.
+IOException
+public JsonWriter nullValue() + throws IOException+
JsonWriter
null
.
++
nullValue
in class JsonWriter
IOException
+public JsonWriter value(boolean value) + throws IOException+
JsonWriter
value
.
++
value
in class JsonWriter
IOException
+public JsonWriter value(double value) + throws IOException+
JsonWriter
value
.
++
value
in class JsonWriter
value
- a finite value. May not be NaNs
or
+ infinities
.
+IOException
+public JsonWriter value(long value) + throws IOException+
JsonWriter
value
.
++
value
in class JsonWriter
IOException
+public JsonWriter value(Number value) + throws IOException+
JsonWriter
value
.
++
value
in class JsonWriter
value
- a finite value. May not be NaNs
or
+ infinities
.
+IOException
+public void flush() + throws IOException+
JsonWriter
Writer
+ and flushes that writer.
++
flush
in class JsonWriter
IOException
+public void close() + throws IOException+
JsonWriter
Writer
.
++
close
in interface Closeable
close
in class JsonWriter
IOException
- if the JSON document is incomplete.
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.MapTypeAdapterFactory ++
public final class MapTypeAdapterFactory
+Adapts maps to either JSON objects or JSON arrays. + +
Maps
to JSON Objects. This requires that map keys
+ can be serialized as strings; this is insufficient for some key types. For
+ example, consider a map whose keys are points on a grid. The default JSON
+ form encodes reasonably: Map<Point, String> original = new LinkedHashMap<Point, String>();
+ original.put(new Point(5, 6), "a");
+ original.put(new Point(8, 8), "b");
+ System.out.println(gson.toJson(original, type));
+
+ The above code prints this JSON object: {
+ "(5,6)": "a",
+ "(8,8)": "b"
+ }
+
+ But GSON is unable to deserialize this value because the JSON string name is
+ just the toString()
of the map key. Attempting to
+ convert the above JSON to an object fails with a parse exception:
+ com.google.gson.JsonParseException: Expecting object found: "(5,6)" + at com.google.gson.JsonObjectDeserializationVisitor.visitFieldUsingCustomHandler + at com.google.gson.ObjectNavigator.navigateClassFields + ...+ +
Register this adapter when you are creating your GSON instance. +
Gson gson = new GsonBuilder()
+ .registerTypeAdapter(Map.class, new MapAsArrayTypeAdapter())
+ .create();
+
+ This will change the structure of the JSON emitted by the code above. Now we
+ get an array. In this case the arrays elements are map entries:
+ [
+ [
+ {
+ "x": 5,
+ "y": 6
+ },
+ "a",
+ ],
+ [
+ {
+ "x": 8,
+ "y": 8
+ },
+ "b"
+ ]
+ ]
+
+ This format will serialize and deserialize just fine as long as this adapter
+ is registered.
++ +
+
+Constructor Summary | +|
---|---|
MapTypeAdapterFactory(ConstructorConstructor constructorConstructor,
+ boolean complexMapKeySerialization)
+
++ |
+
+Method Summary | +||
---|---|---|
+
+ |
+create(MiniGson context,
+ TypeToken<T> typeToken)
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public MapTypeAdapterFactory(ConstructorConstructor constructorConstructor, + boolean complexMapKeySerialization)+
+Method Detail | +
---|
+public <T> TypeAdapter<T> create(MiniGson context, + TypeToken<T> typeToken)+
create
in interface TypeAdapter.Factory
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.MiniGson.Builder ++
public static final class MiniGson.Builder
+
+Constructor Summary | +|
---|---|
MiniGson.Builder()
+
++ |
+
+Method Summary | +||
---|---|---|
+ MiniGson |
+build()
+
++ |
+|
+ MiniGson.Builder |
+factory(TypeAdapter.Factory factory)
+
++ |
+|
+
+ |
+typeAdapter(Class<T> type,
+ TypeAdapter<T> typeAdapter)
+
++ |
+|
+
+ |
+typeAdapter(TypeToken<T> type,
+ TypeAdapter<T> typeAdapter)
+
++ |
+|
+
+ |
+typeHierarchyAdapter(Class<T> type,
+ TypeAdapter<T> typeAdapter)
+
++ |
+|
+ MiniGson.Builder |
+withoutDefaultFactories()
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public MiniGson.Builder()+
+Method Detail | +
---|
+public MiniGson.Builder factory(TypeAdapter.Factory factory)+
+public MiniGson.Builder withoutDefaultFactories()+
+public <T> MiniGson.Builder typeAdapter(Class<T> type, + TypeAdapter<T> typeAdapter)+
+public <T> MiniGson.Builder typeAdapter(TypeToken<T> type, + TypeAdapter<T> typeAdapter)+
+public <T> MiniGson.Builder typeHierarchyAdapter(Class<T> type, + TypeAdapter<T> typeAdapter)+
+public MiniGson build()+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.MiniGson ++
public final class MiniGson
+A basic binding between JSON and Java objects. +
+ +
+
+Nested Class Summary | +|
---|---|
+static class |
+MiniGson.Builder
+
++ |
+
+Method Summary | +||
---|---|---|
+
+ |
+getAdapter(Class<T> type)
+
++ Returns the type adapter for type. |
+|
+
+ |
+getAdapter(TypeToken<T> type)
+
++ Returns the type adapter for type. |
+|
+ List<TypeAdapter.Factory> |
+getFactories()
+
++ Returns the type adapters of this context in order of precedence. |
+|
+
+ |
+getNextAdapter(TypeAdapter.Factory skipPast,
+ TypeToken<T> type)
+
++ Returns a type adapter for type that isn't skipPast . |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Method Detail | +
---|
+public <T> TypeAdapter<T> getAdapter(TypeToken<T> type)+
type.
++
IllegalArgumentException
- if this GSON cannot serialize and
+ deserialize type
.+public <T> TypeAdapter<T> getNextAdapter(TypeAdapter.Factory skipPast, + TypeToken<T> type)+
type that isn't skipPast
. This
+ can be used for type adapters to compose other, simpler type adapters.
++
IllegalArgumentException
- if this GSON cannot serialize and
+ deserialize type
.+public <T> TypeAdapter<T> getAdapter(Class<T> type)+
type.
++
IllegalArgumentException
- if this GSON cannot serialize and
+ deserialize type
.+public List<TypeAdapter.Factory> getFactories()+
+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.TypeAdapter<Object> + com.google.gson.internal.bind.ObjectTypeAdapter ++
public final class ObjectTypeAdapter
+Adapts types whose static type is only 'Object'. Uses getClass() on + serialization and a primitive/Map/List on deserialization. +
+ +
+
+Nested Class Summary | +
---|
Nested classes/interfaces inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
TypeAdapter.Factory |
+
+Field Summary | +|
---|---|
+static TypeAdapter.Factory |
+FACTORY
+
++ |
+
+Method Summary | +|
---|---|
+ Object |
+read(JsonReader reader)
+
++ |
+
+ void |
+write(JsonWriter writer,
+ Object value)
+
++ |
+
Methods inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
fromJson, fromJsonElement, read, toJson, toJsonElement, write |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Field Detail | +
---|
+public static final TypeAdapter.Factory FACTORY+
+Method Detail | +
---|
+public Object read(JsonReader reader) + throws IOException+
read
in class TypeAdapter<Object>
IOException
+public void write(JsonWriter writer, + Object value) + throws IOException+
write
in class TypeAdapter<Object>
IOException
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.TypeAdapter<T> + com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.Adapter<T> ++
public final class ReflectiveTypeAdapterFactory.Adapter<T>
+
+Nested Class Summary | +
---|
Nested classes/interfaces inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
TypeAdapter.Factory |
+
+Method Summary | +|
---|---|
+ T |
+read(JsonReader reader)
+
++ |
+
+ void |
+write(JsonWriter writer,
+ T value)
+
++ |
+
Methods inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
fromJson, fromJsonElement, read, toJson, toJsonElement, write |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Method Detail | +
---|
+public T read(JsonReader reader) + throws IOException+
read
in class TypeAdapter<T>
IOException
+public void write(JsonWriter writer, + T value) + throws IOException+
write
in class TypeAdapter<T>
IOException
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.ReflectiveTypeAdapterFactory ++
public class ReflectiveTypeAdapterFactory
+Type adapter that reflects over the fields and methods of a class. +
+ +
+
+Nested Class Summary | +|
---|---|
+ class |
+ReflectiveTypeAdapterFactory.Adapter<T>
+
++ |
+
+Constructor Summary | +|
---|---|
ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor)
+
++ |
+
+Method Summary | +||
---|---|---|
+
+ |
+create(MiniGson context,
+ TypeToken<T> type)
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor)+
+Method Detail | +
---|
+public <T> TypeAdapter<T> create(MiniGson context, + TypeToken<T> type)+
create
in interface TypeAdapter.Factory
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.TypeAdapter<Date> + com.google.gson.internal.bind.SqlDateTypeAdapter ++
public final class SqlDateTypeAdapter
+Adapter for java.sql.Date. Although this class appears stateless, it is not. + DateFormat captures its time zone and locale when it is created, which gives + this class state. DateFormat isn't thread safe either, so this class has + to synchronize its read and write methods. +
+ +
+
+Nested Class Summary | +
---|
Nested classes/interfaces inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
TypeAdapter.Factory |
+
+Field Summary | +|
---|---|
+static TypeAdapter.Factory |
+FACTORY
+
++ |
+
+Constructor Summary | +|
---|---|
SqlDateTypeAdapter()
+
++ |
+
+Method Summary | +|
---|---|
+ Date |
+read(JsonReader reader)
+
++ |
+
+ void |
+write(JsonWriter writer,
+ Date value)
+
++ |
+
Methods inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
fromJson, fromJsonElement, read, toJson, toJsonElement, write |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Field Detail | +
---|
+public static final TypeAdapter.Factory FACTORY+
+Constructor Detail | +
---|
+public SqlDateTypeAdapter()+
+Method Detail | +
---|
+public Date read(JsonReader reader) + throws IOException+
read
in class TypeAdapter<Date>
IOException
+public void write(JsonWriter writer, + Date value) + throws IOException+
write
in class TypeAdapter<Date>
IOException
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.StringToValueMapTypeAdapterFactory ++
public final class StringToValueMapTypeAdapterFactory
+Adapt a map whose keys are strings. +
+ +
+
+Constructor Summary | +|
---|---|
StringToValueMapTypeAdapterFactory(ConstructorConstructor constructorConstructor)
+
++ |
+
+Method Summary | +||
---|---|---|
+
+ |
+create(MiniGson context,
+ TypeToken<T> typeToken)
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public StringToValueMapTypeAdapterFactory(ConstructorConstructor constructorConstructor)+
+Method Detail | +
---|
+public <T> TypeAdapter<T> create(MiniGson context, + TypeToken<T> typeToken)+
create
in interface TypeAdapter.Factory
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.TypeAdapter<Time> + com.google.gson.internal.bind.TimeTypeAdapter ++
public final class TimeTypeAdapter
+Adapter for Time. Although this class appears stateless, it is not. + DateFormat captures its time zone and locale when it is created, which gives + this class state. DateFormat isn't thread safe either, so this class has + to synchronize its read and write methods. +
+ +
+
+Nested Class Summary | +
---|
Nested classes/interfaces inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
TypeAdapter.Factory |
+
+Field Summary | +|
---|---|
+static TypeAdapter.Factory |
+FACTORY
+
++ |
+
+Constructor Summary | +|
---|---|
TimeTypeAdapter()
+
++ |
+
+Method Summary | +|
---|---|
+ Time |
+read(JsonReader reader)
+
++ |
+
+ void |
+write(JsonWriter writer,
+ Time value)
+
++ |
+
Methods inherited from class com.google.gson.internal.bind.TypeAdapter | +
---|
fromJson, fromJsonElement, read, toJson, toJsonElement, write |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Field Detail | +
---|
+public static final TypeAdapter.Factory FACTORY+
+Constructor Detail | +
---|
+public TimeTypeAdapter()+
+Method Detail | +
---|
+public Time read(JsonReader reader) + throws IOException+
read
in class TypeAdapter<Time>
IOException
+public void write(JsonWriter writer, + Time value) + throws IOException+
write
in class TypeAdapter<Time>
IOException
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
public static interface TypeAdapter.Factory
+
+Method Summary | +||
---|---|---|
+
+ |
+create(MiniGson context,
+ TypeToken<T> type)
+
++ |
+
+Method Detail | +
---|
+<T> TypeAdapter<T> create(MiniGson context, + TypeToken<T> type)+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.TypeAdapter<T> ++
public abstract class TypeAdapter<T>
+
+Nested Class Summary | +|
---|---|
+static interface |
+TypeAdapter.Factory
+
++ |
+
+Constructor Summary | +|
---|---|
TypeAdapter()
+
++ |
+
+Method Summary | +|
---|---|
+ T |
+fromJson(String json)
+
++ |
+
+ T |
+fromJsonElement(JsonElement json)
+
++ |
+
+abstract T |
+read(JsonReader reader)
+
++ |
+
+ T |
+read(Reader in)
+
++ |
+
+ String |
+toJson(T value)
+
++ |
+
+ JsonElement |
+toJsonElement(T src)
+
++ |
+
+abstract void |
+write(JsonWriter writer,
+ T value)
+
++ |
+
+ void |
+write(Writer out,
+ T value)
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public TypeAdapter()+
+Method Detail | +
---|
+public abstract T read(JsonReader reader) + throws IOException+
IOException
+public abstract void write(JsonWriter writer, + T value) + throws IOException+
IOException
+public final String toJson(T value) + throws IOException+
IOException
+public final void write(Writer out, + T value) + throws IOException+
IOException
+public final T fromJson(String json) + throws IOException+
IOException
+public final T read(Reader in) + throws IOException+
IOException
+public JsonElement toJsonElement(T src)+
+public T fromJsonElement(JsonElement json)+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.internal.bind.TypeAdapters ++
public final class TypeAdapters
+Type adapters for basic types. +
+ +
+
+Method Summary | +||
---|---|---|
+static
+ |
+newEnumTypeHierarchyFactory(Class<TT> clazz)
+
++ |
+|
+static
+ |
+newFactory(Class<TT> unboxed,
+ Class<TT> boxed,
+ TypeAdapter<? super TT> typeAdapter)
+
++ |
+|
+static
+ |
+newFactory(Class<TT> type,
+ TypeAdapter<TT> typeAdapter)
+
++ |
+|
+static
+ |
+newFactory(TypeToken<TT> type,
+ TypeAdapter<TT> typeAdapter)
+
++ |
+|
+static
+ |
+newFactoryForMultipleTypes(Class<TT> base,
+ Class<? extends TT> sub,
+ TypeAdapter<? super TT> typeAdapter)
+
++ |
+|
+static
+ |
+newTypeHierarchyFactory(Class<TT> clazz,
+ TypeAdapter<TT> typeAdapter)
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Field Detail | +
---|
+public static final TypeAdapter<BitSet> BIT_SET+
+public static final TypeAdapter.Factory BIT_SET_FACTORY+
+public static final TypeAdapter<Boolean> BOOLEAN+
+public static final TypeAdapter<Boolean> BOOLEAN_AS_STRING+
+
+public static final TypeAdapter.Factory BOOLEAN_FACTORY+
+public static final TypeAdapter<Number> BYTE+
+public static final TypeAdapter.Factory BYTE_FACTORY+
+public static final TypeAdapter<Number> SHORT+
+public static final TypeAdapter.Factory SHORT_FACTORY+
+public static final TypeAdapter<Number> INTEGER+
+public static final TypeAdapter.Factory INTEGER_FACTORY+
+public static final TypeAdapter<Number> LONG+
+public static final TypeAdapter.Factory LONG_FACTORY+
+public static final TypeAdapter<Number> FLOAT+
+public static final TypeAdapter.Factory FLOAT_FACTORY+
+public static final TypeAdapter<Number> DOUBLE+
+public static final TypeAdapter.Factory DOUBLE_FACTORY+
+public static final TypeAdapter<Number> NUMBER+
+public static final TypeAdapter.Factory NUMBER_FACTORY+
+public static final TypeAdapter<Character> CHARACTER+
+public static final TypeAdapter.Factory CHARACTER_FACTORY+
+public static final TypeAdapter<String> STRING+
+public static final TypeAdapter.Factory STRING_FACTORY+
+public static final TypeAdapter<StringBuilder> STRING_BUILDER+
+public static final TypeAdapter.Factory STRING_BUILDER_FACTORY+
+public static final TypeAdapter<StringBuffer> STRING_BUFFER+
+public static final TypeAdapter.Factory STRING_BUFFER_FACTORY+
+public static final TypeAdapter<URL> URL+
+public static final TypeAdapter.Factory URL_FACTORY+
+public static final TypeAdapter<URI> URI+
+public static final TypeAdapter.Factory URI_FACTORY+
+public static final TypeAdapter<InetAddress> INET_ADDRESS+
+public static final TypeAdapter.Factory INET_ADDRESS_FACTORY+
+public static final TypeAdapter<UUID> UUID+
+public static final TypeAdapter.Factory UUID_FACTORY+
+public static final TypeAdapter.Factory TIMESTAMP_FACTORY+
+public static final TypeAdapter<Calendar> CALENDAR+
+public static final TypeAdapter.Factory CALENDAR_FACTORY+
+public static final TypeAdapter<Locale> LOCALE+
+public static final TypeAdapter.Factory LOCALE_FACTORY+
+public static final TypeAdapter<JsonElement> JSON_ELEMENT+
+public static final TypeAdapter.Factory JSON_ELEMENT_FACTORY+
+public static final TypeAdapter.Factory ENUM_FACTORY+
+Method Detail | +
---|
+public static <TT> TypeAdapter.Factory newEnumTypeHierarchyFactory(Class<TT> clazz)+
+public static <TT> TypeAdapter.Factory newFactory(TypeToken<TT> type, + TypeAdapter<TT> typeAdapter)+
+public static <TT> TypeAdapter.Factory newFactory(Class<TT> type, + TypeAdapter<TT> typeAdapter)+
+public static <TT> TypeAdapter.Factory newFactory(Class<TT> unboxed, + Class<TT> boxed, + TypeAdapter<? super TT> typeAdapter)+
+public static <TT> TypeAdapter.Factory newFactoryForMultipleTypes(Class<TT> base, + Class<? extends TT> sub, + TypeAdapter<? super TT> typeAdapter)+
+public static <TT> TypeAdapter.Factory newTypeHierarchyFactory(Class<TT> clazz, + TypeAdapter<TT> typeAdapter)+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use MiniGson.Builder | +|
---|---|
com.google.gson.internal.bind | ++ |
+Uses of MiniGson.Builder in com.google.gson.internal.bind | +
---|
+ +
Methods in com.google.gson.internal.bind that return MiniGson.Builder | +||
---|---|---|
+ MiniGson.Builder |
+MiniGson.Builder.factory(TypeAdapter.Factory factory)
+
++ |
+|
+
+ |
+MiniGson.Builder.typeAdapter(Class<T> type,
+ TypeAdapter<T> typeAdapter)
+
++ |
+|
+
+ |
+MiniGson.Builder.typeAdapter(TypeToken<T> type,
+ TypeAdapter<T> typeAdapter)
+
++ |
+|
+
+ |
+MiniGson.Builder.typeHierarchyAdapter(Class<T> type,
+ TypeAdapter<T> typeAdapter)
+
++ |
+|
+ MiniGson.Builder |
+MiniGson.Builder.withoutDefaultFactories()
+
++ |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use MiniGson | +|
---|---|
com.google.gson.internal.bind | ++ |
+Uses of MiniGson in com.google.gson.internal.bind | +
---|
+ +
Methods in com.google.gson.internal.bind that return MiniGson | +|
---|---|
+ MiniGson |
+MiniGson.Builder.build()
+
++ |
+
+ +
Methods in com.google.gson.internal.bind with parameters of type MiniGson | +||
---|---|---|
+
+ |
+StringToValueMapTypeAdapterFactory.create(MiniGson context,
+ TypeToken<T> typeToken)
+
++ |
+|
+
+ |
+CollectionTypeAdapterFactory.create(MiniGson context,
+ TypeToken<T> typeToken)
+
++ |
+|
+
+ |
+ExcludedTypeAdapterFactory.create(MiniGson context,
+ TypeToken<T> type)
+
++ |
+|
+
+ |
+MapTypeAdapterFactory.create(MiniGson context,
+ TypeToken<T> typeToken)
+
++ |
+|
+
+ |
+ReflectiveTypeAdapterFactory.create(MiniGson context,
+ TypeToken<T> type)
+
++ |
+|
+
+ |
+TypeAdapter.Factory.create(MiniGson context,
+ TypeToken<T> type)
+
++ |
+
+ +
Constructors in com.google.gson.internal.bind with parameters of type MiniGson | +|
---|---|
ArrayTypeAdapter(MiniGson context,
+ TypeAdapter<E> componentTypeAdapter,
+ Class<E> componentType)
+
++ |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use TypeAdapter.Factory | +|
---|---|
com.google.gson.internal.bind | ++ |
+Uses of TypeAdapter.Factory in com.google.gson.internal.bind | +
---|
+ +
Classes in com.google.gson.internal.bind that implement TypeAdapter.Factory | +|
---|---|
+ class |
+CollectionTypeAdapterFactory
+
++ Adapt a homogeneous collection of objects. |
+
+ class |
+ExcludedTypeAdapterFactory
+
++ This type adapter skips values using an exclusion strategy. |
+
+ class |
+MapTypeAdapterFactory
+
++ Adapts maps to either JSON objects or JSON arrays. |
+
+ class |
+ReflectiveTypeAdapterFactory
+
++ Type adapter that reflects over the fields and methods of a class. |
+
+ class |
+StringToValueMapTypeAdapterFactory
+
++ Adapt a map whose keys are strings. |
+
+ +
Fields in com.google.gson.internal.bind declared as TypeAdapter.Factory | +|
---|---|
+static TypeAdapter.Factory |
+TypeAdapters.BIT_SET_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.BOOLEAN_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.BYTE_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.CALENDAR_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.CHARACTER_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.DOUBLE_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.ENUM_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+DateTypeAdapter.FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+ArrayTypeAdapter.FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TimeTypeAdapter.FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+SqlDateTypeAdapter.FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+ObjectTypeAdapter.FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.FLOAT_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.INET_ADDRESS_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.INTEGER_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.JSON_ELEMENT_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.LOCALE_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.LONG_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.NUMBER_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.SHORT_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.STRING_BUFFER_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.STRING_BUILDER_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.STRING_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.TIMESTAMP_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.URI_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.URL_FACTORY
+
++ |
+
+static TypeAdapter.Factory |
+TypeAdapters.UUID_FACTORY
+
++ |
+
+ +
Methods in com.google.gson.internal.bind that return TypeAdapter.Factory | +||
---|---|---|
+static
+ |
+TypeAdapters.newEnumTypeHierarchyFactory(Class<TT> clazz)
+
++ |
+|
+static
+ |
+TypeAdapters.newFactory(Class<TT> unboxed,
+ Class<TT> boxed,
+ TypeAdapter<? super TT> typeAdapter)
+
++ |
+|
+static
+ |
+TypeAdapters.newFactory(Class<TT> type,
+ TypeAdapter<TT> typeAdapter)
+
++ |
+|
+static
+ |
+TypeAdapters.newFactory(TypeToken<TT> type,
+ TypeAdapter<TT> typeAdapter)
+
++ |
+|
+static
+ |
+TypeAdapters.newFactoryForMultipleTypes(Class<TT> base,
+ Class<? extends TT> sub,
+ TypeAdapter<? super TT> typeAdapter)
+
++ |
+|
+static
+ |
+TypeAdapters.newTypeHierarchyFactory(Class<TT> clazz,
+ TypeAdapter<TT> typeAdapter)
+
++ |
+
+ +
Methods in com.google.gson.internal.bind that return types with arguments of type TypeAdapter.Factory | +|
---|---|
+ List<TypeAdapter.Factory> |
+MiniGson.getFactories()
+
++ Returns the type adapters of this context in order of precedence. |
+
+ +
Methods in com.google.gson.internal.bind with parameters of type TypeAdapter.Factory | +||
---|---|---|
+ MiniGson.Builder |
+MiniGson.Builder.factory(TypeAdapter.Factory factory)
+
++ |
+|
+
+ |
+MiniGson.getNextAdapter(TypeAdapter.Factory skipPast,
+ TypeToken<T> type)
+
++ Returns a type adapter for type that isn't skipPast . |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use TypeAdapter | +|
---|---|
com.google.gson.internal.bind | ++ |
+Uses of TypeAdapter in com.google.gson.internal.bind | +
---|
+ +
Subclasses of TypeAdapter in com.google.gson.internal.bind | +|
---|---|
+ class |
+ArrayTypeAdapter<E>
+
++ Adapt an array of objects. |
+
+ class |
+BigDecimalTypeAdapter
+
++ Adapts a BigDecimal type to and from its JSON representation. |
+
+ class |
+BigIntegerTypeAdapter
+
++ Adapts a BigInteger type to and from its JSON representation. |
+
+ class |
+DateTypeAdapter
+
++ Adapter for Date. |
+
+ class |
+ObjectTypeAdapter
+
++ Adapts types whose static type is only 'Object'. |
+
+ class |
+ReflectiveTypeAdapterFactory.Adapter<T>
+
++ |
+
+ class |
+SqlDateTypeAdapter
+
++ Adapter for java.sql.Date. |
+
+ class |
+TimeTypeAdapter
+
++ Adapter for Time. |
+
+ +
Fields in com.google.gson.internal.bind declared as TypeAdapter | +|
---|---|
+static TypeAdapter<BitSet> |
+TypeAdapters.BIT_SET
+
++ |
+
+static TypeAdapter<Boolean> |
+TypeAdapters.BOOLEAN
+
++ |
+
+static TypeAdapter<Boolean> |
+TypeAdapters.BOOLEAN_AS_STRING
+
++ Writes a boolean as a string. |
+
+static TypeAdapter<Number> |
+TypeAdapters.BYTE
+
++ |
+
+static TypeAdapter<Calendar> |
+TypeAdapters.CALENDAR
+
++ |
+
+static TypeAdapter<Character> |
+TypeAdapters.CHARACTER
+
++ |
+
+static TypeAdapter<Number> |
+TypeAdapters.DOUBLE
+
++ |
+
+static TypeAdapter<Number> |
+TypeAdapters.FLOAT
+
++ |
+
+static TypeAdapter<InetAddress> |
+TypeAdapters.INET_ADDRESS
+
++ |
+
+static TypeAdapter<Number> |
+TypeAdapters.INTEGER
+
++ |
+
+static TypeAdapter<JsonElement> |
+TypeAdapters.JSON_ELEMENT
+
++ |
+
+static TypeAdapter<Locale> |
+TypeAdapters.LOCALE
+
++ |
+
+static TypeAdapter<Number> |
+TypeAdapters.LONG
+
++ |
+
+static TypeAdapter<Number> |
+TypeAdapters.NUMBER
+
++ |
+
+static TypeAdapter<Number> |
+TypeAdapters.SHORT
+
++ |
+
+static TypeAdapter<String> |
+TypeAdapters.STRING
+
++ |
+
+static TypeAdapter<StringBuffer> |
+TypeAdapters.STRING_BUFFER
+
++ |
+
+static TypeAdapter<StringBuilder> |
+TypeAdapters.STRING_BUILDER
+
++ |
+
+static TypeAdapter<URI> |
+TypeAdapters.URI
+
++ |
+
+static TypeAdapter<URL> |
+TypeAdapters.URL
+
++ |
+
+static TypeAdapter<UUID> |
+TypeAdapters.UUID
+
++ |
+
+ +
Methods in com.google.gson.internal.bind that return TypeAdapter | +||
---|---|---|
+
+ |
+StringToValueMapTypeAdapterFactory.create(MiniGson context,
+ TypeToken<T> typeToken)
+
++ |
+|
+
+ |
+CollectionTypeAdapterFactory.create(MiniGson context,
+ TypeToken<T> typeToken)
+
++ |
+|
+
+ |
+ExcludedTypeAdapterFactory.create(MiniGson context,
+ TypeToken<T> type)
+
++ |
+|
+
+ |
+MapTypeAdapterFactory.create(MiniGson context,
+ TypeToken<T> typeToken)
+
++ |
+|
+
+ |
+ReflectiveTypeAdapterFactory.create(MiniGson context,
+ TypeToken<T> type)
+
++ |
+|
+
+ |
+TypeAdapter.Factory.create(MiniGson context,
+ TypeToken<T> type)
+
++ |
+|
+
+ |
+MiniGson.getAdapter(Class<T> type)
+
++ Returns the type adapter for type. |
+|
+
+ |
+MiniGson.getAdapter(TypeToken<T> type)
+
++ Returns the type adapter for type. |
+|
+
+ |
+MiniGson.getNextAdapter(TypeAdapter.Factory skipPast,
+ TypeToken<T> type)
+
++ Returns a type adapter for type that isn't skipPast . |
+
+ +
Methods in com.google.gson.internal.bind with parameters of type TypeAdapter | +||
---|---|---|
+static
+ |
+TypeAdapters.newFactory(Class<TT> unboxed,
+ Class<TT> boxed,
+ TypeAdapter<? super TT> typeAdapter)
+
++ |
+|
+static
+ |
+TypeAdapters.newFactory(Class<TT> type,
+ TypeAdapter<TT> typeAdapter)
+
++ |
+|
+static
+ |
+TypeAdapters.newFactory(TypeToken<TT> type,
+ TypeAdapter<TT> typeAdapter)
+
++ |
+|
+static
+ |
+TypeAdapters.newFactoryForMultipleTypes(Class<TT> base,
+ Class<? extends TT> sub,
+ TypeAdapter<? super TT> typeAdapter)
+
++ |
+|
+static
+ |
+TypeAdapters.newTypeHierarchyFactory(Class<TT> clazz,
+ TypeAdapter<TT> typeAdapter)
+
++ |
+|
+
+ |
+MiniGson.Builder.typeAdapter(Class<T> type,
+ TypeAdapter<T> typeAdapter)
+
++ |
+|
+
+ |
+MiniGson.Builder.typeAdapter(TypeToken<T> type,
+ TypeAdapter<T> typeAdapter)
+
++ |
+|
+
+ |
+MiniGson.Builder.typeHierarchyAdapter(Class<T> type,
+ TypeAdapter<T> typeAdapter)
+
++ |
+
+ +
Constructors in com.google.gson.internal.bind with parameters of type TypeAdapter | +|
---|---|
ArrayTypeAdapter(MiniGson context,
+ TypeAdapter<E> componentTypeAdapter,
+ Class<E> componentType)
+
++ |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Interfaces
+
+ +TypeAdapter.Factory |
+
+Classes
+
+ +ArrayTypeAdapter + +BigDecimalTypeAdapter + +BigIntegerTypeAdapter + +CollectionTypeAdapterFactory + +DateTypeAdapter + +ExcludedTypeAdapterFactory + +JsonElementReader + +JsonElementWriter + +MapTypeAdapterFactory + +MiniGson + +MiniGson.Builder + +ObjectTypeAdapter + +ReflectiveTypeAdapterFactory + +SqlDateTypeAdapter + +StringToValueMapTypeAdapterFactory + +TimeTypeAdapter + +TypeAdapter + +TypeAdapters |
+
+
+
|
++ + | +|||||||||
+ PREV PACKAGE + NEXT PACKAGE | ++ FRAMES + NO FRAMES + + + + + | +
+Interface Summary | +|
---|---|
TypeAdapter.Factory | ++ |
+ +
+Class Summary | +|
---|---|
ArrayTypeAdapter<E> | +Adapt an array of objects. | +
BigDecimalTypeAdapter | +Adapts a BigDecimal type to and from its JSON representation. | +
BigIntegerTypeAdapter | +Adapts a BigInteger type to and from its JSON representation. | +
CollectionTypeAdapterFactory | +Adapt a homogeneous collection of objects. | +
DateTypeAdapter | +Adapter for Date. | +
ExcludedTypeAdapterFactory | +This type adapter skips values using an exclusion strategy. | +
JsonElementReader | +This reader walks the elements of a JsonElement as if it was coming from a + character stream. | +
JsonElementWriter | +This writer creates a JsonElement. | +
MapTypeAdapterFactory | +Adapts maps to either JSON objects or JSON arrays. | +
MiniGson | +A basic binding between JSON and Java objects. | +
MiniGson.Builder | ++ |
ObjectTypeAdapter | +Adapts types whose static type is only 'Object'. | +
ReflectiveTypeAdapterFactory | +Type adapter that reflects over the fields and methods of a class. | +
SqlDateTypeAdapter | +Adapter for java.sql.Date. | +
StringToValueMapTypeAdapterFactory | +Adapt a map whose keys are strings. | +
TimeTypeAdapter | +Adapter for Time. | +
TypeAdapter<T> | ++ |
TypeAdapters | +Type adapters for basic types. | +
+
+
+
|
++ + | +|||||||||
+ PREV PACKAGE + NEXT PACKAGE | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use com.google.gson.internal.bind | +|
---|---|
com.google.gson.internal.bind | ++ |
+Classes in com.google.gson.internal.bind used by com.google.gson.internal.bind | +|
---|---|
MiniGson
+
+ + A basic binding between JSON and Java objects. |
+|
MiniGson.Builder
+
+ + |
+|
TypeAdapter
+
+ + |
+|
TypeAdapter.Factory
+
+ + |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use ConstructorConstructor | +|
---|---|
com.google.gson.internal.bind | ++ |
+Uses of ConstructorConstructor in com.google.gson.internal.bind | +
---|
+ +
Constructors in com.google.gson.internal.bind with parameters of type ConstructorConstructor | +|
---|---|
CollectionTypeAdapterFactory(ConstructorConstructor constructorConstructor)
+
++ |
+|
MapTypeAdapterFactory(ConstructorConstructor constructorConstructor,
+ boolean complexMapKeySerialization)
+
++ |
+|
ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor)
+
++ |
+|
StringToValueMapTypeAdapterFactory(ConstructorConstructor constructorConstructor)
+
++ |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use ObjectConstructor | +|
---|---|
com.google.gson.internal | +Do NOT use any class in this package as they are meant for internal use in Gson. | +
+Uses of ObjectConstructor in com.google.gson.internal | +
---|
+ +
Methods in com.google.gson.internal that return ObjectConstructor | +||
---|---|---|
+
+ |
+ConstructorConstructor.getConstructor(TypeToken<T> typeToken)
+
++ |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use Pair | +|
---|---|
com.google.gson.internal | +Do NOT use any class in this package as they are meant for internal use in Gson. | +
+Uses of Pair in com.google.gson.internal | +
---|
+ +
Methods in com.google.gson.internal with parameters of type Pair | +|
---|---|
+ void |
+ParameterizedTypeHandlerMap.registerForTypeHierarchy(Pair<Class<?>,T> pair,
+ boolean isSystem)
+
++ |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use ParameterizedTypeHandlerMap | +|
---|---|
com.google.gson.internal | +Do NOT use any class in this package as they are meant for internal use in Gson. | +
+Uses of ParameterizedTypeHandlerMap in com.google.gson.internal | +
---|
+ +
Methods in com.google.gson.internal that return ParameterizedTypeHandlerMap | +|
---|---|
+ ParameterizedTypeHandlerMap<T> |
+ParameterizedTypeHandlerMap.copyOf()
+
++ |
+
+ ParameterizedTypeHandlerMap<T> |
+ParameterizedTypeHandlerMap.makeUnmodifiable()
+
++ |
+
+ +
Methods in com.google.gson.internal with parameters of type ParameterizedTypeHandlerMap | +|
---|---|
+ void |
+ParameterizedTypeHandlerMap.registerIfAbsent(ParameterizedTypeHandlerMap<T> other)
+
++ |
+
+ +
Constructors in com.google.gson.internal with parameters of type ParameterizedTypeHandlerMap | +|
---|---|
ConstructorConstructor(ParameterizedTypeHandlerMap<InstanceCreator<?>> instanceCreators)
+
++ |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use UnsafeAllocator | +|
---|---|
com.google.gson.internal | +Do NOT use any class in this package as they are meant for internal use in Gson. | +
+Uses of UnsafeAllocator in com.google.gson.internal | +
---|
+ +
Methods in com.google.gson.internal that return UnsafeAllocator | +|
---|---|
+static UnsafeAllocator |
+UnsafeAllocator.create()
+
++ |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Interfaces
+
+ +ObjectConstructor |
+
+Classes
+
+ +$Gson$Preconditions + +$Gson$Types + +ConstructorConstructor + +LazilyParsedNumber + +Pair + +ParameterizedTypeHandlerMap + +Primitives + +Streams + +UnsafeAllocator |
+
+
+
|
++ + | +|||||||||
+ PREV PACKAGE + NEXT PACKAGE | ++ FRAMES + NO FRAMES + + + + + | +
+See:
+
+ Description
+
+ +
+Interface Summary | +|
---|---|
ObjectConstructor<T> | +Defines a generic object construction factory. | +
+ +
+Class Summary | +|
---|---|
$Gson$Preconditions | +A simple utility class used to check method Preconditions. | +
$Gson$Types | +Static methods for working with types. | +
ConstructorConstructor | +Returns a function that can construct an instance of a requested type. | +
LazilyParsedNumber | +This class holds a number value that is lazily converted to a specific number type | +
Pair<FIRST,SECOND> | +A simple object that holds onto a pair of object references, first and second. | +
ParameterizedTypeHandlerMap<T> | +A map that provides ability to associate handlers for a specific type or all + of its sub-types | +
Primitives | +Contains static utility methods pertaining to primitive types and their + corresponding wrapper types. | +
Streams | +Reads and writes GSON parse trees over streams. | +
UnsafeAllocator | +Do sneaky things to allocate objects without invoking their constructors. | +
+Do NOT use any class in this package as they are meant for internal use in Gson. + These classes will very likely change incompatibly in future versions. You have been warned. +
+ +
+
+
+
|
++ + | +|||||||||
+ PREV PACKAGE + NEXT PACKAGE | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use com.google.gson.internal | +|
---|---|
com.google.gson.internal | +Do NOT use any class in this package as they are meant for internal use in Gson. | +
com.google.gson.internal.bind | ++ |
+Classes in com.google.gson.internal used by com.google.gson.internal | +|
---|---|
ObjectConstructor
+
+ + Defines a generic object construction factory. |
+|
Pair
+
+ + A simple object that holds onto a pair of object references, first and second. |
+|
ParameterizedTypeHandlerMap
+
+ + A map that provides ability to associate handlers for a specific type or all + of its sub-types |
+|
UnsafeAllocator
+
+ + Do sneaky things to allocate objects without invoking their constructors. |
+
+Classes in com.google.gson.internal used by com.google.gson.internal.bind | +|
---|---|
ConstructorConstructor
+
+ + Returns a function that can construct an instance of a requested type. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Interfaces
+
+ +ExclusionStrategy + +FieldNamingStrategy + +InstanceCreator + +JsonDeserializationContext + +JsonDeserializer + +JsonSerializationContext + +JsonSerializer |
+
+Classes
+
+ +FieldAttributes + +Gson + +GsonBuilder + +JsonArray + +JsonElement + +JsonNull + +JsonObject + +JsonParser + +JsonPrimitive + +JsonStreamParser |
+
+Enums
+
+ +FieldNamingPolicy + +LongSerializationPolicy |
+
+Exceptions
+
+ +JsonIOException + +JsonParseException + +JsonSyntaxException |
+
+
+
|
++ + | +|||||||||
+ PREV PACKAGE + NEXT PACKAGE | ++ FRAMES + NO FRAMES + + + + + | +
Gson
class to convert Json to Java and
+ vice-versa.
+
+See:
+
+ Description
+
+ +
+Interface Summary | +|
---|---|
ExclusionStrategy | +A strategy (or policy) definition that is used to decide whether or not a field or top-level + class should be serialized or deserialized as part of the JSON output/input. | +
FieldNamingStrategy | +A mechanism for providing custom field naming in Gson. | +
InstanceCreator<T> | +This interface is implemented to create instances of a class that does not define a no-args + constructor. | +
JsonDeserializationContext | +Context for deserialization that is passed to a custom deserializer during invocation of its
+ JsonDeserializer.deserialize(JsonElement, Type, JsonDeserializationContext)
+ method. |
+
JsonDeserializer<T> | +Interface representing a custom deserializer for Json. | +
JsonSerializationContext | +Context for serialization that is passed to a custom serializer during invocation of its
+ JsonSerializer.serialize(Object, Type, JsonSerializationContext) method. |
+
JsonSerializer<T> | +Interface representing a custom serializer for Json. | +
+ +
+Class Summary | +|
---|---|
FieldAttributes | +A data object that stores attributes of a field. | +
Gson | +This is the main class for using Gson. | +
GsonBuilder | +Use this builder to construct a Gson instance when you need to set configuration
+ options other than the default. |
+
JsonArray | +A class representing an array type in Json. | +
JsonElement | +A class representing an element of Json. | +
JsonNull | +A class representing a Json null value. |
+
JsonObject | +A class representing an object type in Json. | +
JsonParser | +A parser to parse Json into a parse tree of JsonElement s |
+
JsonPrimitive | +A class representing a Json primitive value. | +
JsonStreamParser | +A streaming parser that allows reading of multiple JsonElement s from the specified reader
+ asynchronously. |
+
+ +
+Enum Summary | +|
---|---|
FieldNamingPolicy | +An enumeration that defines a few standard naming conventions for JSON field names. | +
LongSerializationPolicy | +Defines the expected format for a long or Long type when its serialized. |
+
+ +
+Exception Summary | +|
---|---|
JsonIOException | +This exception is raised when Gson was unable to read an input stream + or write to one. | +
JsonParseException | +This exception is raised if there is a serious issue that occurs during parsing of a Json + string. | +
JsonSyntaxException | +This exception is raised when Gson attempts to read (or write) a malformed + JSON element. | +
+This package provides the Gson
class to convert Json to Java and
+ vice-versa.
+
+
The primary class to use is Gson
which can be constructed with
+ new Gson()
(using default settings) or by using GsonBuilder
+ (to configure various options such as using versioning and so on).
+ +
+
+
+
|
++ + | +|||||||||
+ PREV PACKAGE + NEXT PACKAGE | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use com.google.gson | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Classes in com.google.gson used by com.google.gson | +|
---|---|
ExclusionStrategy
+
+ + A strategy (or policy) definition that is used to decide whether or not a field or top-level + class should be serialized or deserialized as part of the JSON output/input. |
+|
FieldAttributes
+
+ + A data object that stores attributes of a field. |
+|
FieldNamingPolicy
+
+ + An enumeration that defines a few standard naming conventions for JSON field names. |
+|
FieldNamingStrategy
+
+ + A mechanism for providing custom field naming in Gson. |
+|
Gson
+
+ + This is the main class for using Gson. |
+|
GsonBuilder
+
+ + Use this builder to construct a Gson instance when you need to set configuration
+ options other than the default. |
+|
JsonArray
+
+ + A class representing an array type in Json. |
+|
JsonDeserializationContext
+
+ + Context for deserialization that is passed to a custom deserializer during invocation of its + JsonDeserializer.deserialize(JsonElement, Type, JsonDeserializationContext)
+ method. |
+|
JsonElement
+
+ + A class representing an element of Json. |
+|
JsonIOException
+
+ + This exception is raised when Gson was unable to read an input stream + or write to one. |
+|
JsonNull
+
+ + A class representing a Json null value. |
+|
JsonObject
+
+ + A class representing an object type in Json. |
+|
JsonParseException
+
+ + This exception is raised if there is a serious issue that occurs during parsing of a Json + string. |
+|
JsonPrimitive
+
+ + A class representing a Json primitive value. |
+|
JsonSerializationContext
+
+ + Context for serialization that is passed to a custom serializer during invocation of its + JsonSerializer.serialize(Object, Type, JsonSerializationContext) method. |
+|
JsonSyntaxException
+
+ + This exception is raised when Gson attempts to read (or write) a malformed + JSON element. |
+|
LongSerializationPolicy
+
+ + Defines the expected format for a long or Long type when its serialized. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.reflect.TypeToken<T> ++
public class TypeToken<T>
+Represents a generic type T
. Java doesn't yet provide a way to
+ represent generic types, so this class does. Forces clients to create a
+ subclass of this class which enables retrieval the type information even at
+ runtime.
+
+
For example, to create a type literal for List<String>
, you can
+ create an empty anonymous inner class:
+
+
+ TypeToken<List<String>> list = new TypeToken<List<String>>() {};
+
+
This syntax cannot be used to create type literals that have wildcard
+ parameters, such as Class<?>
or List<? extends CharSequence>
.
+
+ +
+
+Method Summary | +||
---|---|---|
+ boolean |
+equals(Object o)
+
++ |
+|
+static
+ |
+get(Class<T> type)
+
++ Gets type literal for the given Class instance. |
+|
+static TypeToken<?> |
+get(Type type)
+
++ Gets type literal for the given Type instance. |
+|
+ Class<? super T> |
+getRawType()
+
++ Returns the raw (non-generic) type for this type. |
+|
+ Type |
+getType()
+
++ Gets underlying Type instance. |
+|
+ int |
+hashCode()
+
++ |
+|
+ boolean |
+isAssignableFrom(Class<?> cls)
+
++ Deprecated. this implementation may be inconsistent with javac for types + with wildcards. |
+|
+ boolean |
+isAssignableFrom(Type from)
+
++ Deprecated. this implementation may be inconsistent with javac for types + with wildcards. |
+|
+ boolean |
+isAssignableFrom(TypeToken<?> token)
+
++ Deprecated. this implementation may be inconsistent with javac for types + with wildcards. |
+|
+ String |
+toString()
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
getClass, notify, notifyAll, wait, wait, wait |
+
+Method Detail | +
---|
+public final Class<? super T> getRawType()+
+
+public final Type getType()+
Type
instance.
++
+@Deprecated +public boolean isAssignableFrom(Class<?> cls)+
+
+
+@Deprecated +public boolean isAssignableFrom(Type from)+
+
+
+@Deprecated +public boolean isAssignableFrom(TypeToken<?> token)+
+
+
+public final int hashCode()+
hashCode
in class Object
+public final boolean equals(Object o)+
equals
in class Object
+public final String toString()+
toString
in class Object
+public static TypeToken<?> get(Type type)+
Type
instance.
++
+public static <T> TypeToken<T> get(Class<T> type)+
Class
instance.
++
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use TypeToken | +|
---|---|
com.google.gson.reflect | +This package provides utility classes for finding type information for generic types. | +
+Uses of TypeToken in com.google.gson.reflect | +
---|
+ +
Methods in com.google.gson.reflect that return TypeToken | +||
---|---|---|
+static
+ |
+TypeToken.get(Class<T> type)
+
++ Gets type literal for the given Class instance. |
+|
+static TypeToken<?> |
+TypeToken.get(Type type)
+
++ Gets type literal for the given Type instance. |
+
+ +
Methods in com.google.gson.reflect with parameters of type TypeToken | +|
---|---|
+ boolean |
+TypeToken.isAssignableFrom(TypeToken<?> token)
+
++ Deprecated. this implementation may be inconsistent with javac for types + with wildcards. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Classes
+
+ +TypeToken |
+
+
+
|
++ + | +|||||||||
+ PREV PACKAGE + NEXT PACKAGE | ++ FRAMES + NO FRAMES + + + + + | +
+See:
+
+ Description
+
+ +
+Class Summary | +|
---|---|
TypeToken<T> | +Represents a generic type T . |
+
+This package provides utility classes for finding type information for generic types. +
+ +
+
+
+
|
++ + | +|||||||||
+ PREV PACKAGE + NEXT PACKAGE | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use com.google.gson.reflect | +|
---|---|
com.google.gson.reflect | +This package provides utility classes for finding type information for generic types. | +
+Classes in com.google.gson.reflect used by com.google.gson.reflect | +|
---|---|
TypeToken
+
+ + Represents a generic type T . |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.stream.JsonReader ++
public class JsonReader
+Reads a JSON (RFC 4627) + encoded value as a stream of tokens. This stream includes both literal + values (strings, numbers, booleans, and nulls) as well as the begin and + end delimiters of objects and arrays. The tokens are traversed in + depth-first order, the same order that they appear in the JSON document. + Within JSON objects, name/value pairs are represented by a single token. + +
JsonReader
.
+
+ Next, create handler methods for each structure in your JSON text. You'll + need a method for each object type and for each array type. +
beginArray()
to consume the array's opening bracket. Then create a
+ while loop that accumulates values, terminating when hasNext()
+ is false. Finally, read the array's closing bracket by calling endArray()
.
+ beginObject()
to consume the object's opening brace. Then create a
+ while loop that assigns values to local variables based on their name.
+ This loop should terminate when hasNext()
is false. Finally,
+ read the object's closing brace by calling endObject()
.
+ When a nested object or array is encountered, delegate to the + corresponding handler method. + +
When an unknown name is encountered, strict parsers should fail with an
+ exception. Lenient parsers should call skipValue()
to recursively
+ skip the value's nested tokens, which may otherwise conflict.
+
+
If a value may be null, you should first check using peek()
.
+ Null literals can be consumed using either nextNull()
or skipValue()
.
+
+
[
+ {
+ "id": 912345678901,
+ "text": "How do I read a JSON stream in Java?",
+ "geo": null,
+ "user": {
+ "name": "json_newb",
+ "followers_count": 41
+ }
+ },
+ {
+ "id": 912345678902,
+ "text": "@json_newb just use JsonReader!",
+ "geo": [50.454722, -104.606667],
+ "user": {
+ "name": "jesse",
+ "followers_count": 2
+ }
+ }
+ ]
+ This code implements the parser for the above structure: public List<Message> readJsonStream(InputStream in) throws IOException {
+ JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));
+ return readMessagesArray(reader);
+ }
+
+ public List<Message> readMessagesArray(JsonReader reader) throws IOException {
+ List<Message> messages = new ArrayList<Message>();
+
+ reader.beginArray();
+ while (reader.hasNext()) {
+ messages.add(readMessage(reader));
+ }
+ reader.endArray();
+ return messages;
+ }
+
+ public Message readMessage(JsonReader reader) throws IOException {
+ long id = -1;
+ String text = null;
+ User user = null;
+ List<Double> geo = null;
+
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String name = reader.nextName();
+ if (name.equals("id")) {
+ id = reader.nextLong();
+ } else if (name.equals("text")) {
+ text = reader.nextString();
+ } else if (name.equals("geo") && reader.peek() != JsonToken.NULL) {
+ geo = readDoublesArray(reader);
+ } else if (name.equals("user")) {
+ user = readUser(reader);
+ } else {
+ reader.skipValue();
+ }
+ }
+ reader.endObject();
+ return new Message(id, text, user, geo);
+ }
+
+ public List<Double> readDoublesArray(JsonReader reader) throws IOException {
+ List<Double> doubles = new ArrayList<Double>();
+
+ reader.beginArray();
+ while (reader.hasNext()) {
+ doubles.add(reader.nextDouble());
+ }
+ reader.endArray();
+ return doubles;
+ }
+
+ public User readUser(JsonReader reader) throws IOException {
+ String username = null;
+ int followersCount = -1;
+
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String name = reader.nextName();
+ if (name.equals("name")) {
+ username = reader.nextString();
+ } else if (name.equals("followers_count")) {
+ followersCount = reader.nextInt();
+ } else {
+ reader.skipValue();
+ }
+ }
+ reader.endObject();
+ return new User(username, followersCount);
+ }
+
+ [1, "1"]
may be read using either nextInt()
or nextString()
.
+ This behavior is intended to prevent lossy numeric conversions: double is
+ JavaScript's only numeric type and very large values like 9007199254740993
cannot be represented exactly on that platform. To minimize
+ precision loss, extremely large values should be written and read as strings
+ in JSON.
+
+ <script>
tag.
+
+ Prefixing JSON files with ")]}'\n"
makes them non-executable
+ by <script>
tags, disarming the attack. Since the prefix is malformed
+ JSON, strict parsing fails when it is encountered. This class permits the
+ non-execute prefix when lenient parsing
is
+ enabled.
+
+
Each JsonReader
may be used to read a single JSON stream. Instances
+ of this class are not thread safe.
+
+ +
+
+Constructor Summary | +|
---|---|
JsonReader(Reader in)
+
++ Creates a new instance that reads a JSON-encoded stream from in . |
+
+Method Summary | +|
---|---|
+ void |
+beginArray()
+
++ Consumes the next token from the JSON stream and asserts that it is the + beginning of a new array. |
+
+ void |
+beginObject()
+
++ Consumes the next token from the JSON stream and asserts that it is the + beginning of a new object. |
+
+ void |
+close()
+
++ Closes this JSON reader and the underlying Reader . |
+
+ void |
+endArray()
+
++ Consumes the next token from the JSON stream and asserts that it is the + end of the current array. |
+
+ void |
+endObject()
+
++ Consumes the next token from the JSON stream and asserts that it is the + end of the current array. |
+
+ boolean |
+hasNext()
+
++ Returns true if the current array or object has another element. |
+
+ boolean |
+isLenient()
+
++ Returns true if this parser is liberal in what it accepts. |
+
+ boolean |
+nextBoolean()
+
++ Returns the boolean value of the next token,
+ consuming it. |
+
+ double |
+nextDouble()
+
++ Returns the double value of the next token,
+ consuming it. |
+
+ int |
+nextInt()
+
++ Returns the int value of the next token,
+ consuming it. |
+
+ long |
+nextLong()
+
++ Returns the long value of the next token,
+ consuming it. |
+
+ String |
+nextName()
+
++ Returns the next token, a property name , and
+ consumes it. |
+
+ void |
+nextNull()
+
++ Consumes the next token from the JSON stream and asserts that it is a + literal null. |
+
+ String |
+nextString()
+
++ Returns the string value of the next token,
+ consuming it. |
+
+ JsonToken |
+peek()
+
++ Returns the type of the next token without consuming it. |
+
+ void |
+setLenient(boolean lenient)
+
++ Configure this parser to be be liberal in what it accepts. |
+
+ void |
+skipValue()
+
++ Skips the next value recursively. |
+
+ String |
+toString()
+
++ |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public JsonReader(Reader in)+
in
.
++
+Method Detail | +
---|
+public final void setLenient(boolean lenient)+
")]}'\n"
.
+ NaNs
or infinities
.
+ //
or #
and
+ ending with a newline character.
+ /*
and ending with
+ *
/
. Such comments may not be nested.
+ 'single quoted'
.
+ 'single quoted'
.
+ ;
instead of ,
.
+ =
or =>
instead of
+ :
.
+ ;
instead of ,
.
+ +
+public final boolean isLenient()+
+
+public void beginArray() + throws IOException+
+
IOException
+public void endArray() + throws IOException+
+
IOException
+public void beginObject() + throws IOException+
+
IOException
+public void endObject() + throws IOException+
+
IOException
+public boolean hasNext() + throws IOException+
+
IOException
+public JsonToken peek() + throws IOException+
+
IOException
+public String nextName() + throws IOException+
property name
, and
+ consumes it.
++
IOException
- if the next token in the stream is not a property
+ name.+public String nextString() + throws IOException+
string
value of the next token,
+ consuming it. If the next token is a number, this method will return its
+ string form.
++
IllegalStateException
- if the next token is not a string or if
+ this reader is closed.
+IOException
+public boolean nextBoolean() + throws IOException+
boolean
value of the next token,
+ consuming it.
++
IllegalStateException
- if the next token is not a boolean or if
+ this reader is closed.
+IOException
+public void nextNull() + throws IOException+
+
IllegalStateException
- if the next token is not null or if this
+ reader is closed.
+IOException
+public double nextDouble() + throws IOException+
double
value of the next token,
+ consuming it. If the next token is a string, this method will attempt to
+ parse it as a double.
++
IllegalStateException
- if the next token is not a literal value.
+NumberFormatException
- if the next literal value cannot be parsed
+ as a double, or is non-finite.
+IOException
+public long nextLong() + throws IOException+
long
value of the next token,
+ consuming it. If the next token is a string, this method will attempt to
+ parse it as a long. If the next token's numeric value cannot be exactly
+ represented by a Java long
, this method throws.
++
IllegalStateException
- if the next token is not a literal value.
+NumberFormatException
- if the next literal value cannot be parsed
+ as a number, or exactly represented as a long.
+IOException
+public int nextInt() + throws IOException+
int
value of the next token,
+ consuming it. If the next token is a string, this method will attempt to
+ parse it as an int. If the next token's numeric value cannot be exactly
+ represented by a Java int
, this method throws.
++
IllegalStateException
- if the next token is not a literal value.
+NumberFormatException
- if the next literal value cannot be parsed
+ as a number, or exactly represented as an int.
+IOException
+public void close() + throws IOException+
Reader
.
++
close
in interface Closeable
IOException
+public void skipValue() + throws IOException+
+
IOException
+public String toString()+
toString
in class Object
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | ++DETAIL: ENUM CONSTANTS | FIELD | METHOD | +
+java.lang.Object + java.lang.Enum<JsonToken> + com.google.gson.stream.JsonToken ++
public enum JsonToken
+A structure, name or value type in a JSON-encoded string. +
+ +
+
+Enum Constant Summary | +|
---|---|
BEGIN_ARRAY
+
++ The opening of a JSON array. |
+|
BEGIN_OBJECT
+
++ The opening of a JSON object. |
+|
BOOLEAN
+
++ A JSON true or false . |
+|
END_ARRAY
+
++ The closing of a JSON array. |
+|
END_DOCUMENT
+
++ The end of the JSON stream. |
+|
END_OBJECT
+
++ The closing of a JSON object. |
+|
NAME
+
++ A JSON property name. |
+|
NULL
+
++ A JSON null . |
+|
NUMBER
+
++ A JSON number represented in this API by a Java double , long , or int . |
+|
STRING
+
++ A JSON string. |
+
+Method Summary | +|
---|---|
+static JsonToken |
+valueOf(String name)
+
++ Returns the enum constant of this type with the specified name. |
+
+static JsonToken[] |
+values()
+
++ Returns an array containing the constants of this enum type, in +the order they are declared. |
+
Methods inherited from class java.lang.Enum | +
---|
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
+
Methods inherited from class java.lang.Object | +
---|
getClass, notify, notifyAll, wait, wait, wait |
+
+Enum Constant Detail | +
---|
+public static final JsonToken BEGIN_ARRAY+
JsonWriter.beginObject()
+ and read using JsonReader.beginObject()
.
++
+public static final JsonToken END_ARRAY+
JsonWriter.endArray()
+ and read using JsonReader.endArray()
.
++
+public static final JsonToken BEGIN_OBJECT+
JsonWriter.beginObject()
+ and read using JsonReader.beginObject()
.
++
+public static final JsonToken END_OBJECT+
JsonWriter.endObject()
+ and read using JsonReader.endObject()
.
++
+public static final JsonToken NAME+
JsonWriter.name(java.lang.String)
and read using JsonReader.nextName()
++
+public static final JsonToken STRING+
+
+public static final JsonToken NUMBER+
double
, long
, or int
.
++
+public static final JsonToken BOOLEAN+
true
or false
.
++
+public static final JsonToken NULL+
null
.
++
+public static final JsonToken END_DOCUMENT+
JsonReader.peek()
to signal that the JSON-encoded value has no more
+ tokens.
++
+Method Detail | +
---|
+public static JsonToken[] values()+
+for (JsonToken c : JsonToken.values()) + System.out.println(c); ++
+
+public static JsonToken valueOf(String name)+
+
name
- the name of the enum constant to be returned.
+IllegalArgumentException
- if this enum type has no constant
+with the specified name
+NullPointerException
- if the argument is null
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | ++DETAIL: ENUM CONSTANTS | FIELD | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + com.google.gson.stream.JsonWriter ++
public class JsonWriter
+Writes a JSON (RFC 4627) + encoded value to a stream, one token at a time. The stream includes both + literal values (strings, numbers, booleans and nulls) as well as the begin + and end delimiters of objects and arrays. + +
JsonWriter
. Each JSON
+ document must contain one top-level array or object. Call methods on the
+ writer as you walk the structure's contents, nesting arrays and objects as
+ necessary:
+ beginArray()
.
+ Write each of the array's elements with the appropriate value(java.lang.String)
+ methods or by nesting other arrays and objects. Finally close the array
+ using endArray()
.
+ beginObject()
.
+ Write each of the object's properties by alternating calls to
+ name(java.lang.String)
with the property's value. Write property values with the
+ appropriate value(java.lang.String)
method or by nesting other objects or arrays.
+ Finally close the object using endObject()
.
+ [
+ {
+ "id": 912345678901,
+ "text": "How do I stream JSON in Java?",
+ "geo": null,
+ "user": {
+ "name": "json_newb",
+ "followers_count": 41
+ }
+ },
+ {
+ "id": 912345678902,
+ "text": "@json_newb just use JsonWriter!",
+ "geo": [50.454722, -104.606667],
+ "user": {
+ "name": "jesse",
+ "followers_count": 2
+ }
+ }
+ ]
+ This code encodes the above structure: public void writeJsonStream(OutputStream out, List<Message> messages) throws IOException {
+ JsonWriter writer = new JsonWriter(new OutputStreamWriter(out, "UTF-8"));
+ writer.setIndentSpaces(4);
+ writeMessagesArray(writer, messages);
+ writer.close();
+ }
+
+ public void writeMessagesArray(JsonWriter writer, List<Message> messages) throws IOException {
+ writer.beginArray();
+ for (Message message : messages) {
+ writeMessage(writer, message);
+ }
+ writer.endArray();
+ }
+
+ public void writeMessage(JsonWriter writer, Message message) throws IOException {
+ writer.beginObject();
+ writer.name("id").value(message.getId());
+ writer.name("text").value(message.getText());
+ if (message.getGeo() != null) {
+ writer.name("geo");
+ writeDoublesArray(writer, message.getGeo());
+ } else {
+ writer.name("geo").nullValue();
+ }
+ writer.name("user");
+ writeUser(writer, message.getUser());
+ writer.endObject();
+ }
+
+ public void writeUser(JsonWriter writer, User user) throws IOException {
+ writer.beginObject();
+ writer.name("name").value(user.getName());
+ writer.name("followers_count").value(user.getFollowersCount());
+ writer.endObject();
+ }
+
+ public void writeDoublesArray(JsonWriter writer, List<Double> doubles) throws IOException {
+ writer.beginArray();
+ for (Double value : doubles) {
+ writer.value(value);
+ }
+ writer.endArray();
+ }
+
+ Each JsonWriter
may be used to write a single JSON stream.
+ Instances of this class are not thread safe. Calls that would result in a
+ malformed JSON string will fail with an IllegalStateException
.
+
+ +
+
+Constructor Summary | +|
---|---|
JsonWriter(Writer out)
+
++ Creates a new instance that writes a JSON-encoded stream to out . |
+
+Method Summary | +|
---|---|
+ JsonWriter |
+beginArray()
+
++ Begins encoding a new array. |
+
+ JsonWriter |
+beginObject()
+
++ Begins encoding a new object. |
+
+ void |
+close()
+
++ Flushes and closes this writer and the underlying Writer . |
+
+ JsonWriter |
+endArray()
+
++ Ends encoding the current array. |
+
+ JsonWriter |
+endObject()
+
++ Ends encoding the current object. |
+
+ void |
+flush()
+
++ Ensures all buffered data is written to the underlying Writer
+ and flushes that writer. |
+
+ boolean |
+getSerializeNulls()
+
++ Returns true if object members are serialized when their value is null. |
+
+ boolean |
+isHtmlSafe()
+
++ Returns true if this writer writes JSON that's safe for inclusion in HTML + and XML documents. |
+
+ boolean |
+isLenient()
+
++ Returns true if this writer has relaxed syntax rules. |
+
+ JsonWriter |
+name(String name)
+
++ Encodes the property name. |
+
+ JsonWriter |
+nullValue()
+
++ Encodes null . |
+
+ void |
+setHtmlSafe(boolean htmlSafe)
+
++ Configure this writer to emit JSON that's safe for direct inclusion in HTML + and XML documents. |
+
+ void |
+setIndent(String indent)
+
++ Sets the indentation string to be repeated for each level of indentation + in the encoded document. |
+
+ void |
+setLenient(boolean lenient)
+
++ Configure this writer to relax its syntax rules. |
+
+ void |
+setSerializeNulls(boolean serializeNulls)
+
++ Sets whether object members are serialized when their value is null. |
+
+ JsonWriter |
+value(boolean value)
+
++ Encodes value . |
+
+ JsonWriter |
+value(double value)
+
++ Encodes value . |
+
+ JsonWriter |
+value(long value)
+
++ Encodes value . |
+
+ JsonWriter |
+value(Number value)
+
++ Encodes value . |
+
+ JsonWriter |
+value(String value)
+
++ Encodes value . |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
+
+Constructor Detail | +
---|
+public JsonWriter(Writer out)+
out
.
+ For best performance, ensure Writer
is buffered; wrapping in
+ BufferedWriter
if necessary.
++
+Method Detail | +
---|
+public final void setIndent(String indent)+
indent.isEmpty()
the encoded document
+ will be compact. Otherwise the encoded document will be more
+ human-readable.
++
indent
- a string containing only whitespace.+public final void setLenient(boolean lenient)+
NaNs
or infinities
.
+ +
+public boolean isLenient()+
+
+public final void setHtmlSafe(boolean htmlSafe)+
<
, >
,
+ &
and =
before writing them to the stream. Without this
+ setting, your XML/HTML encoder should replace these characters with the
+ corresponding escape sequences.
++
+public final boolean isHtmlSafe()+
+
+public final void setSerializeNulls(boolean serializeNulls)+
+
+public final boolean getSerializeNulls()+
+
+public JsonWriter beginArray() + throws IOException+
endArray()
.
++
IOException
+public JsonWriter endArray() + throws IOException+
+
IOException
+public JsonWriter beginObject() + throws IOException+
endObject()
.
++
IOException
+public JsonWriter endObject() + throws IOException+
+
IOException
+public JsonWriter name(String name) + throws IOException+
+
name
- the name of the forthcoming value. May not be null.
+IOException
+public JsonWriter value(String value) + throws IOException+
value
.
++
value
- the literal string value, or null to encode a null literal.
+IOException
+public JsonWriter nullValue() + throws IOException+
null
.
++
IOException
+public JsonWriter value(boolean value) + throws IOException+
value
.
++
IOException
+public JsonWriter value(double value) + throws IOException+
value
.
++
value
- a finite value. May not be NaNs
or
+ infinities
.
+IOException
+public JsonWriter value(long value) + throws IOException+
value
.
++
IOException
+public JsonWriter value(Number value) + throws IOException+
value
.
++
value
- a finite value. May not be NaNs
or
+ infinities
.
+IOException
+public void flush() + throws IOException+
Writer
+ and flushes that writer.
++
IOException
+public void close() + throws IOException+
Writer
.
++
close
in interface Closeable
IOException
- if the JSON document is incomplete.
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+java.lang.Object + java.lang.Throwable + java.lang.Exception + java.io.IOException + com.google.gson.stream.MalformedJsonException ++
public final class MalformedJsonException
+Thrown when a reader encounters malformed JSON. Some syntax errors can be
+ ignored by calling JsonReader.setLenient(boolean)
.
+
+ +
+
+Constructor Summary | +|
---|---|
MalformedJsonException(String msg)
+
++ |
+|
MalformedJsonException(String msg,
+ Throwable throwable)
+
++ |
+|
MalformedJsonException(Throwable throwable)
+
++ |
+
+Method Summary | +
---|
Methods inherited from class java.lang.Throwable | +
---|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
+
Methods inherited from class java.lang.Object | +
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
+
+Constructor Detail | +
---|
+public MalformedJsonException(String msg)+
+public MalformedJsonException(String msg, + Throwable throwable)+
+public MalformedJsonException(Throwable throwable)+
+
+
|
++ + | +|||||||||
+ PREV CLASS + NEXT CLASS | ++ FRAMES + NO FRAMES + + + + + | +|||||||||
+ SUMMARY: NESTED | FIELD | CONSTR | METHOD | ++DETAIL: FIELD | CONSTR | METHOD | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use JsonReader | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
+Uses of JsonReader in com.google.gson | +
---|
+ +
Methods in com.google.gson with parameters of type JsonReader | +||
---|---|---|
+
+ |
+Gson.fromJson(JsonReader reader,
+ Type typeOfT)
+
++ Reads the next JSON value from reader and convert it to an object
+ of type typeOfT . |
+|
+ JsonElement |
+JsonParser.parse(JsonReader json)
+
++ Returns the next value from the JSON stream as a parse tree. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use JsonToken | +|
---|---|
com.google.gson.stream | ++ |
+Uses of JsonToken in com.google.gson.stream | +
---|
+ +
Methods in com.google.gson.stream that return JsonToken | +|
---|---|
+ JsonToken |
+JsonReader.peek()
+
++ Returns the type of the next token without consuming it. |
+
+static JsonToken |
+JsonToken.valueOf(String name)
+
++ Returns the enum constant of this type with the specified name. |
+
+static JsonToken[] |
+JsonToken.values()
+
++ Returns an array containing the constants of this enum type, in +the order they are declared. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use JsonWriter | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
com.google.gson.stream | ++ |
+Uses of JsonWriter in com.google.gson | +
---|
+ +
Methods in com.google.gson with parameters of type JsonWriter | +|
---|---|
+ void |
+Gson.toJson(JsonElement jsonElement,
+ JsonWriter writer)
+
++ Writes the JSON for jsonElement to writer . |
+
+ void |
+Gson.toJson(Object src,
+ Type typeOfSrc,
+ JsonWriter writer)
+
++ Writes the JSON representation of src of type typeOfSrc to
+ writer . |
+
+Uses of JsonWriter in com.google.gson.stream | +
---|
+ +
Methods in com.google.gson.stream that return JsonWriter | +|
---|---|
+ JsonWriter |
+JsonWriter.beginArray()
+
++ Begins encoding a new array. |
+
+ JsonWriter |
+JsonWriter.beginObject()
+
++ Begins encoding a new object. |
+
+ JsonWriter |
+JsonWriter.endArray()
+
++ Ends encoding the current array. |
+
+ JsonWriter |
+JsonWriter.endObject()
+
++ Ends encoding the current object. |
+
+ JsonWriter |
+JsonWriter.name(String name)
+
++ Encodes the property name. |
+
+ JsonWriter |
+JsonWriter.nullValue()
+
++ Encodes null . |
+
+ JsonWriter |
+JsonWriter.value(boolean value)
+
++ Encodes value . |
+
+ JsonWriter |
+JsonWriter.value(double value)
+
++ Encodes value . |
+
+ JsonWriter |
+JsonWriter.value(long value)
+
++ Encodes value . |
+
+ JsonWriter |
+JsonWriter.value(Number value)
+
++ Encodes value . |
+
+ JsonWriter |
+JsonWriter.value(String value)
+
++ Encodes value . |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Classes
+
+ +JsonReader + +JsonWriter |
+
+Enums
+
+ +JsonToken |
+
+Exceptions
+
+ +MalformedJsonException |
+
+
+
|
++ + | +|||||||||
+ PREV PACKAGE + NEXT PACKAGE | ++ FRAMES + NO FRAMES + + + + + | +
+Class Summary | +|
---|---|
JsonReader | +Reads a JSON (RFC 4627) + encoded value as a stream of tokens. | +
JsonWriter | +Writes a JSON (RFC 4627) + encoded value to a stream, one token at a time. | +
+ +
+Enum Summary | +|
---|---|
JsonToken | +A structure, name or value type in a JSON-encoded string. | +
+ +
+Exception Summary | +|
---|---|
MalformedJsonException | +Thrown when a reader encounters malformed JSON. | +
+
+
+
|
++ + | +|||||||||
+ PREV PACKAGE + NEXT PACKAGE | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages that use com.google.gson.stream | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
com.google.gson.stream | ++ |
+Classes in com.google.gson.stream used by com.google.gson | +|
---|---|
JsonReader
+
+ + Reads a JSON (RFC 4627) + encoded value as a stream of tokens. |
+|
JsonWriter
+
+ + Writes a JSON (RFC 4627) + encoded value to a stream, one token at a time. |
+
+Classes in com.google.gson.stream used by com.google.gson.stream | +|
---|---|
JsonToken
+
+ + A structure, name or value type in a JSON-encoded string. |
+|
JsonWriter
+
+ + Writes a JSON (RFC 4627) + encoded value to a stream, one token at a time. |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Deprecated Methods | +|
---|---|
com.google.gson.reflect.TypeToken.isAssignableFrom(Class>)
+ + this implementation may be inconsistent with javac for types + with wildcards. |
+|
com.google.gson.reflect.TypeToken.isAssignableFrom(Type)
+ + this implementation may be inconsistent with javac for types + with wildcards. |
+|
com.google.gson.reflect.TypeToken.isAssignableFrom(TypeToken>)
+ + this implementation may be inconsistent with javac for types + with wildcards. |
+
+Deprecated Constructors | +|
---|---|
com.google.gson.JsonNull()
+ + |
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+ +++The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.
+ +++Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:
+
+- Interfaces (italic)
- Classes
- Enums
- Exceptions
- Errors
- Annotation Types
+ ++ ++Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
+
+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.- Class inheritance diagram
- Direct Subclasses
- All Known Subinterfaces
- All Known Implementing Classes
- Class/interface declaration
- Class/interface description +
+
- Nested Class Summary
- Field Summary
- Constructor Summary
- Method Summary +
+
- Field Detail
- Constructor Detail
- Method Detail
+ ++ ++Each annotation type has its own separate page with the following sections:
+
+- Annotation Type declaration
- Annotation Type description
- Required Element Summary
- Optional Element Summary
- Element Detail
+ +++Each enum has its own separate page with the following sections:
+
+- Enum declaration
- Enum description
- Enum Constant Summary
- Enum Constant Detail
+Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.+
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with+java.lang.Object
. The interfaces do not inherit fromjava.lang.Object
.+
+- When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
- When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
+The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.+
+
+
+
+
+This help file applies to API documentation generated using the standard doclet.
+
+
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
Reader
.
+Writer
.
+Gson
class to convert Json to Java and
+ vice-versa.Gson
.Gson
instance based on the current configuration.
+Expose
annotation.
+Writer
+ and flushes that writer.
+reader
and convert it to an object
+ of type typeOfT
.
+Type
instance.
+Class
instance.
+T
annotation object from this field if it exist; otherwise returns
+ null
.
+BigDecimal
if it contains a single element.
+BigDecimal
.
+BigDecimal
.
+BigInteger
if it contains a single element.
+BigInteger
.
+BigInteger
.
+JsonArray
.
+JsonNull
.
+JsonObject
.
+JsonPrimitive
.
+Number
if it contains a single element.
+Number
.
+String
if it contains a single element.
+Class
object that was declared for this field.
++ public class Foo { + private String bar; + private List<String> red; + } + + Type listParmeterizedType = new TypeToken<List<String>>() {}.getType(); +
Type
instance.
+Gson
instance when you need to set configuration
+ options other than the default.true
if the field is defined with the modifier
.
+JsonElement
is available on the input for consumption
+JsonDeserializer.deserialize(JsonElement, Type, JsonDeserializationContext)
+ method.null
value.JsonElement
sNumber
.
+in
.
+JsonSerializer.serialize(Object, Type, JsonSerializationContext)
method.JsonElement
s from the specified reader
+ asynchronously.out
.
+long
or Long
type when its serialized.JsonElement
on the reader.
+boolean
value of the next token,
+ consuming it.
+double
value of the next token,
+ consuming it.
+int
value of the next token,
+ consuming it.
+long
value of the next token,
+ consuming it.
+property name
, and
+ consumes it.
+string
value of the next token,
+ consuming it.
+null
.
+property
from this JsonObject
.
+Iterator
method is not relevant for stream parsing and hence is not
+ implemented.
+value
using this serialization policy.
+Date
objects according to the pattern provided.
+Date
objects according to the style value provided.
+Date
objects according to the style value provided.
+Long
and long
+ objects.
+src
of type typeOfSrc
to
+ writer
.
+JsonElement
s into its equivalent JSON representation.
+JsonElement
s.
+jsonElement
to writer
.
+JsonElement
s.
+JsonElement
s.
+T
.value
.
+value
.
+value
.
+value
.
+value
.
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+ | +
---|
All Classes
+
+
+Packages
+ |
+
+ + + diff --git a/gson/docs/javadocs/overview-summary.html b/gson/docs/javadocs/overview-summary.html new file mode 100644 index 00000000..58538a75 --- /dev/null +++ b/gson/docs/javadocs/overview-summary.html @@ -0,0 +1,170 @@ + + + +
+ + +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Packages | +|
---|---|
com.google.gson | +This package provides the Gson class to convert Json to Java and
+ vice-versa. |
+
com.google.gson.annotations | +This package provides annotations that can be used with Gson . |
+
com.google.gson.reflect | +This package provides utility classes for finding type information for generic types. | +
com.google.gson.stream | ++ |
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +
+Package com.google.gson | +
---|
+Class com.google.gson.JsonIOException extends JsonParseException implements Serializable | +
---|
+serialVersionUID: 1L + +
+ +
+Class com.google.gson.JsonParseException extends RuntimeException implements Serializable | +
---|
+serialVersionUID: -4086729973971783390L + +
+ +
+Class com.google.gson.JsonSyntaxException extends JsonParseException implements Serializable | +
---|
+serialVersionUID: 1L + +
+
+Package com.google.gson.stream | +
---|
+Class com.google.gson.stream.MalformedJsonException extends IOException implements Serializable | +
---|
+serialVersionUID: 1L + +
+ +
+
+
+
|
++ + | +|||||||||
+ PREV + NEXT | ++ FRAMES + NO FRAMES + + + + + | +