0

I am developing a Java EE webapp using JBoss AS 7 and Resteasy. I would like to do the Communication with the Rest Interface using the Jettison JAXB/JSon Provider.

As a demo I implemented the following JAXB annotated class:

@XmlRootElement(name = "test")
@XmlAccessorType(XmlAccessType.FIELD)
public class TestJson
{
    @XmlElement
    public int      id      = 1;

    @XmlElement
    public String   name    = "hello";

    public TestJson()
    {}

}

To get the object I implemented the following webservice:

@BadgerFish
@GET
@Produces(MediaType.APPLICATION_JSON)
public TestJson getJSON()
{

    return new TestJson();


}

now if I do the GET request I get the following response:

!!com.example.TestJson {id: 1, name: hello}

I would be expecting

{"id":1, "name":"hello"}

am I doing something wrong here? (unmarshalling JSON Objects works like a charm)

thanks for any hints.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
saberrider
  • 585
  • 3
  • 16

0 Answers0