Rectangle 27 0

java XStream to use getter for serialization?


XStream xstream = new XStream();
xstream.registerConverter(new JavaBeanConverter(xstream.getClassMapper(), "class"), -20);
Note
Rectangle 27 0

java XStream to use getter for serialization?


@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
public class KeyValuePair {

    @JsonProperty
    private int value;
    @JsonProperty
    private String key;
}

I was looking for the XStream XML annotation. Sorry if the question wasn't clear.

If you make the fields public, Jackson can use them instead of getter/setter methods. There is also an annotation @JsonProperty to cause that.

Thanks, would you be able to tell me which annotation? I been searching for it and couldn't find anything.

Note