Class JdkTypeAdapterFactory
- All Implemented Interfaces:
com.google.gson.TypeAdapterFactory
TypeAdapterFactory for the value types of java.time
and for TimeZone, whose fields Gson cannot access by reflection on
Java 17 and later.
Available in ZK EE
A java.time value is written and read as the JSON object that
Gson made of its fields by reflection on Java 11, such as
{"year":2024,"month":1,"day":2} for a LocalDate; a field
value that the type rejects, such as a month of 13, causes a
JsonSyntaxException. A TimeZone of the JDK is written as
the rawOffset and ID of that object only, since its other
fields are internal to the JDK, and it is read by its ID with
TimeZone.getTimeZone(String), so reading it as a
SimpleTimeZone causes a JsonSyntaxException.
GsonConverter and GsonConverter
register it. An application that specifies its own converter with the
library property org.zkoss.zk.ui.jsonServiceParamConverter.class
or org.zkoss.bind.jsonBindingParamConverter.class can register it
with GsonBuilder.registerTypeAdapterFactory(com.google.gson.TypeAdapterFactory).
- Since:
- 11.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> com.google.gson.TypeAdapter<T>create(com.google.gson.Gson gson, com.google.gson.reflect.TypeToken<T> type)
-
Constructor Details
-
JdkTypeAdapterFactory
public JdkTypeAdapterFactory()
-
-
Method Details
-
create
public <T> com.google.gson.TypeAdapter<T> create(com.google.gson.Gson gson, com.google.gson.reflect.TypeToken<T> type) - Specified by:
createin interfacecom.google.gson.TypeAdapterFactory
-