I have the following class:
public class Message {
private String text;
public String getText() {
return text;
}
public void setText(St
It was sad to learn that you must write custom serialization for the simple goal of wrapping a class with a labeled object. After playing around with writing a custom serializer, I concluded that the simplest solution is a generic wrapper. Here's perhaps a more simple implementation of your example above:
public final class JsonObjectWrapper {
private JsonObjectWrapper() {}
public static Map withLabel(String label, E wrappedObject) {
HashMap map = new HashMap();
map.put(label, wrappedObject);
return map;
}
}