How can I serialize Enum in JAX-RS resources JSON responses in JBoss EAP 6?

Solution In Progress - Updated -

Issue

We would like to know how to serialize enum attributes from an object. Currently it returns the enum String value, for example, I have the enum:

public enum TaskType {
    WORK("Work", "Work related tasks"), PROJECTS("Project", "Project related tasks"), HOME("Home",
            "Home related tasks");
    private String name;
    private String description;
    // get e set
}

Which I use in an object:

public class Task {

private TaskType type;

}

When returning it as an object we have only the enum value e.g. WORK, but we would like to have the enum represented as a object with its fields. How can I achieve that?

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.4

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content