lundi 4 mai 2020

How to convert Annotation Interface to JSON?

I am trying to read custom annotation value loaded through a different classloader.

How do I convert the Annotation object to json?

@Retention(RententionPolicy.RUNTIME)
public @interface SendEmail{
public String id;
}

Gson gson = new Gson();

Object object = (Object)annotation // this holds SendEmail object loaded from different classloader

gson.toJson(object); 

//I get UnsupportedOperationException: Attempted to Serialize java.lang.Class: SendEmail. Forget to register a type adapter?

What is the type adapter to be used for interfaces?





Aucun commentaire:

Enregistrer un commentaire