Java Custom annotation for String Json

时间:2017-06-15 10:36:58

标签: java json annotations

I have following interface.

interface MyInterface {
      public String getJsonString()
}

There is an implementation of this interface. getJsonString returns a string(json) representation of (some) ABC class.

I want to introduce custom annotation @JsonToObject as following:

interface MyInterface {

      @JsonToObject(ABC.class)
      public String getMyString()

}

@JsonToObject Annotation should converts returned String to ABC class object using Jackson. And returns the ABC class object. If not possible just throw exception.

Basically, convert the returned string to given class object.

Is this possible?

I am using Spring for DI.

Thanks in advance.

0 个答案:

没有答案