| 构造器和说明 |
|---|
DateAdapter() |
| 限定符和类型 | 方法和说明 |
|---|---|
Date |
deserialize(com.google.gson.JsonElement json,
Type typeOfT,
com.google.gson.JsonDeserializationContext context)
Gson invokes this call-back method during deserialization when it encounters a field of the
specified type.
|
static void |
main(String[] args) |
com.google.gson.JsonElement |
serialize(Date src,
Type typeOfSrc,
com.google.gson.JsonSerializationContext context)
Gson invokes this call-back method during serialization when it encounters a field of the
specified type.
|
public Date deserialize(com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context) throws com.google.gson.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).
deserialize 在接口中 com.google.gson.JsonDeserializer<Date>json - The Json data being deserializedtypeOfT - The type of the Object to deserialize toTcom.google.gson.JsonParseException - if json is not in the expected format of typeofTpublic com.google.gson.JsonElement serialize(Date src, Type typeOfSrc, com.google.gson.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).
serialize 在接口中 com.google.gson.JsonSerializer<Date>src - the object that needs to be converted to Json.typeOfSrc - the actual type (fully genericized version) of the source object.public static void main(String[] args) throws ParseException
ParseExceptionCopyright © 2021. All rights reserved.