Interface JsonConverter
public interface JsonConverter
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription<T> TDeserializes an object of the specified type from its JSON representation.<T> TfromObject(@NonNull Type type, Object content) Converts an object to a different type using JSON mapping logic as an intermediary.Serializes an object of the specified type to its JSON representation.
-
Field Details
-
NONE
-
-
Method Details
-
toJson
String toJson(@NonNull @NonNull Type type, @Nullable Object o) throws ConversionException, UnsupportedOperationException Serializes an object of the specified type to its JSON representation.- Parameters:
type- object typeo- object to serialize (can benull)- Returns:
- JSON representation of the serialized object, as a String
- Throws:
ConversionException- could not serializeUnsupportedOperationException- serialization not supported
-
fromJson
<T> T fromJson(@NonNull @NonNull Type type, @NonNull @NonNull String content) throws ConversionException, UnsupportedOperationException Deserializes an object of the specified type from its JSON representation.- Parameters:
type- object typecontent- JSON to deserialize, as a String- Throws:
ConversionException- could not deserializeUnsupportedOperationException- deserialization not supported
-
fromObject
<T> T fromObject(@NonNull @NonNull Type type, @Nullable Object content) throws ConversionException, UnsupportedOperationException Converts an object to a different type using JSON mapping logic as an intermediary.- Parameters:
type- type to convert the object tocontent- object to convert (can benull)- Returns:
- converted object
- Throws:
ConversionException- could not convertUnsupportedOperationException- conversion not supported
-