Hi , i have a question about deserializer / serial...
# announcements
Hi , i have a question about deserializer / serializer, i got this Error:
Copy code
java.lang.IllegalArgumentException: @JsonAdapter value must be TypeAdapter or TypeAdapterFactory reference.
	at com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory.getTypeAdapter(JsonAdapterAnnotationTypeAdapterFactory.java:64)
	at com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory.create(JsonAdapterAnnotationTypeAdapterFactory.java:46)
	at com.google.gson.Gson.getAdapter(Gson.java:359)
	at com.google.gson.Gson.toJson(Gson.java:592)
	at com.google.gson.Gson.toJson(Gson.java:579)
	at com.google.gson.Gson.toJson(Gson.java:534)
	at com.google.gson.Gson.toJson(Gson.java:514)
	at Util.SparkUtilKt.prepare(SparkUtil.kt:50)
This is my data class:
Copy code
data class User(
        val userName: String,
        val password: String,
        val email: String
) : Serializable

class UserDeserializer : JsonDeserializer<User> {
    override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): User {
        json ?: throw IllegalStateException("JSON does not exist")
        typeOfT ?: throw IllegalStateException("Type does not exist")
        context ?: throw IllegalStateException("DeserializationContext does not exist")

        val jSon = json.asJsonObject

        return User(
                userName = jSon.get("username").safeString(context),
                password = jSon.get("password").safeString(context),
                email = jSon.get("email").safeString(context)
the code is triggered like this:
Copy code
Spark.get("/user", { request, response ->
            val user = User(
                    userName = "Username",
                    password = "pass",
                    email = "<mailto:test@mail.com|test@mail.com>"
            response.prepare(200, user)
////// here is prepare 
 * This function helps us format our responses
fun Response.prepare(statusCode: Int, content: Any): String {
    return body()