public interface JsonSerializer
During the serialization the JSON name of the fields will be the same as in java.
To change that, you can use SerializedName annotation on the java field.
| Modifier and Type | Method and Description |
|---|---|
String |
toJson(Object src)
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.
|
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.src - the object for which JSON representation is to be createdsrcString toJson(Object src, Type typeOfSrc)
toJson(Object) instead.src - the object for which JSON representation is to be createdtypeOfSrc - the specific genericized type of srcsrcCreated by Kornél Simon, 2022