- Type Parameters:
T- target type, may be unchecked
- All Known Subinterfaces:
Jose.Extension<T>
public interface IuJsonAdapter<T>
Adapts JSON values to equivalent Java types.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> IuJsonAdapter<T> basic()Provides a basic JSON type adapter.static <T> IuJsonAdapter<T> from(Class<T> type, IuJsonPropertyNameFormat propertyNameFormat, Function<Type, IuJsonAdapter<?>> valueAdapter) Creates a JSON type adapter that converts from a JavaBeans business object type to and from JSON.static <T> IuJsonAdapter<T> Creates a functional JSON type adapter.static <T> IuJsonAdapter<T> Creates a functional JSON type adapter.Converts a JSON parameter value to its Java equivalent.static <T> IuJsonAdapter<T> of(Class<? super T> type, IuJsonAdapter<?> valueAdapter) Provides a JSON type adapter that delegates to another adapter for parameterized values.static <T> IuJsonAdapter<T> Provides a standard JSON type adapter for a Java value.static <T> IuJsonAdapter<T> Provides a JSON type adapter for the erasure of a generic type.static <T> IuJsonAdapter<T> of(Type type, Function<Class<?>, IuJsonAdapter<?>> valueAdapter) Provides a JSON type adapter that delegates to another adapter for parameterized values.static <T> IuJsonAdapter<T> Creates a functional JSON type adapter for text conversion.static <T> IuJsonAdapter<T> Creates a functional JSON type adapter.static <T> IuJsonAdapter<T> Creates a functional JSON type adapter.Converts a value to its JSON equivalent.
-
Method Details
-
from
Creates a functional JSON type adapter.- Type Parameters:
T- target type- Parameters:
fromJson- function that converts from JSON to the target type- Returns:
- functional adapter
-
text
Creates a functional JSON type adapter for text conversion.- Type Parameters:
T- target type- Parameters:
parser- parsing function- Returns:
- functional adapter
-
text
Creates a functional JSON type adapter.- Type Parameters:
T- target type- Parameters:
parser- parsing functionprint- printing function- Returns:
- functional adapter
-
to
Creates a functional JSON type adapter.- Type Parameters:
T- target type- Parameters:
toJson- function that converts from the target type to JSON- Returns:
- functional adapter
-
from
Creates a functional JSON type adapter.- Type Parameters:
T- target type- Parameters:
fromJson- function that converts from JSON to the target typetoJson- function that converts from the target type to JSON- Returns:
- functional adapter
-
from
static <T> IuJsonAdapter<T> from(Class<T> type, IuJsonPropertyNameFormat propertyNameFormat, Function<Type, IuJsonAdapter<?>> valueAdapter) Creates a JSON type adapter that converts from a JavaBeans business object type to and from JSON.- Type Parameters:
T- business object type- Parameters:
type- business object class; must be an interface to convert from JSON, an interface is not required to convert from JSON.propertyNameFormat- property name format to use for converting to JSONvalueAdapter- value adapter function- Returns:
IuJsonAdapter
-
basic
Provides a basic JSON type adapter.Returns an adapter that:
- Handles undefined (null) JSON values as null
- Returns
JsonValueas-is - Builds
JsonObjectBuilderandJsonArrayBuilderif provided totoJson(Object)as Java values - Converts between null and
JsonValue.NULL - Converts between
BooleanandJsonValue.TRUE/JsonValue.FALSE - Converts between
StringandJsonString - Converts between
NumberandJsonNumber,fromJson(JsonValue)returnsBigDecimal - Converts between
List<?>andJsonArray, with recursive item conversion - Converts between
Map<String, ?>andJsonObject, with recursive conversion - Converts irreversibly to
JsonValuefor other types listed inof(Class).
Equivalent to
of(Object.class)- Type Parameters:
T- target type, may be used for unchecked cast to a one of the types listed above. For full generic type support and two-way conversion useof(Class)- Returns:
IuJsonAdapter- Throws:
ClassCastException- (potentially upstream) If the target type doesn't match the return type
-
of
Provides a JSON type adapter for the erasure of a generic type.The adapter returned is aware of
ParameterizedTypeandGenericArrayTypearguments indicating item, component, and value types. All types referenced by generic type arguments must be included in the list below.Supports:
BooleanandbooleanObject, seebasic()for Object conversion rulesVoidandvoid, supporting only null valuestoJson(Object)asJsonNumbertoJson(Object)returnsJsonString- byte[], via
IuText.base64(String)andIuText.base64(byte[]) BigIntegerCharSequenceCalendar, asDateCharSequence, asStringDate, asTemporalDurationEnumsubtypesInstantLocalDateLocalTimeLocalDateTimeOffsetDateTimeOffsetTimeOptionalPeriodSimpleTimeZoneStringPatternTimeZoneURIURLZonedDateTimeZoneIdZoneOffset
- byte[], via
toJson(Object)asJsonArrayArraytypeArrayListCollection, asQueueDeque, asArrayDequeEnumerationHashSetIterable, asCollectionIteratorLinkedHashSetList, asArrayListNavigableSet, asTreeSetQueue, asDequeSet, asLinkedHashSetSortedSet, asNavigableSetProperties, enforces values asStringTreeSetStream
toJson(Object)asJsonObject:
- Type Parameters:
T- target type- Parameters:
type- target type- Returns:
IuJsonAdapter
-
of
Provides a standard JSON type adapter for a Java value.- Type Parameters:
T- target type- Parameters:
type- target type- Returns:
IuJsonAdapter- See Also:
-
of
Provides a JSON type adapter that delegates to another adapter for parameterized values.- Type Parameters:
T- target type- Parameters:
type- target typevalueAdapter- Value type adapter forJsonStructureconversion, may be null if the Java type doesn't declare parameters, or to use a standard value adapter- Returns:
IuJsonAdapter- See Also:
-
of
Provides a JSON type adapter that delegates to another adapter for parameterized values.- Type Parameters:
T- target type- Parameters:
type- target typevalueAdapter- Factory function for supplying a value type adapter forJsonStructureconversion based on the item type.- Returns:
IuJsonAdapter- See Also:
-
fromJson
Converts a JSON parameter value to its Java equivalent.- Parameters:
jsonValue- JSON value- Returns:
- Java equivalent
-
toJson
Converts a value to its JSON equivalent.- Parameters:
value- value- Returns:
- JSON equivalent
-