jeudi 10 décembre 2015

Is it possible to use Jackson to obtain value from Pojo

Jackson takes many factors into account when naming a field for serialization into JSON. Is it possible to use those factors in reverse in order to retrieve the value of a field in a pojo based on the name it will have once serialized?

For example, given the bean

public class Bean{
    private String prop;

    @JsonProperty("property")
    public String getProp();
}

Is it possible to get the value of prop given only a configured ObjectMapper, the string "property" and an instance of Bean?

I know about reflection, so if I could just get "prop" or "getProp" I would be pretty much good to go.





Aucun commentaire:

Enregistrer un commentaire