Let's say I have the following Java enum:
@AllArgsConstructor
public enum Code {
Code1("Short text 1", "Long text 1"),
Code2("Short text 2", "Long text 2");
private final String shorttext;
private final String longtext;
}
Then System.out.println(JsonbBuilder.create().toJson(Code.Code1))
will result in ""Code1"
. I would like to have the following result:
{
"shorttext": "Short text 1",
"longtext": "Long text 1"
}
Is there a comfortable way to achive this? Maybe any Annotation I can use? Or is it mandatory to implement a custom Adapter?
By the way: org.json.JSONObject
results in the desired format by default.