Hi,
I have been evaluating cxf-2.2.4.jar and I need some help for the following
issues.
Issue 1 :
Is there any support for getting JSON in Badgerfish and Jettison-Mapped
notations in cxf-2.2.4? If yes, please tell me the configuration to get JSON
any one of these notations.
If no, by when do you plan to suport these notations.
Issue 2 :
Marshalling and unmarshalling of a list containing objects of a subclass of the
Type of the list.
In this example Client is a subclass of Customer.
@Path("/customerservice/")
public class CustomerService {
@GET
@Produces("application/json")
@Path("/myobject/")
public MyObject getCustomerList() {
List<Customer> list = new ArrayList<Customer>();
Client client = new Client();
client.setName("firstClient");
client.setId(10000000);
client.setClientId("9999999");
Customer c = new Customer();
c.setName("aaa");
c.setId(111);
list.add(c);
list.add(client);
MyObject m = new MyObject();
m.setList(list);
return m;
}
}
The JSON for the list given by cxf is :
{"myObject":{"list":[{"id":111,"name":"aaa"},{"id":10000000,"name":"firstClient"}]}}
where as the JSON given by jersey-bundle-1.0.2.jar is :
{"myObject":{"list":[{"id":"111","name":"aaa"},{"@type":"client","id":"10000000","name":"firstClient","clientId":"9999999"}]}}
The JSON given by jersey-bundle-1.0.2.jar is more helpful in some cases. Can
you please provide similar support in cxf too.
Java classes for the above example
@XmlRootElement
public class MyObject {
List<Customer> list = new ArrayList<Customer>();
public List<Customer> getList() {
return list;
}
public void setList(List<Customer> list) {
this.list = list;
}
}
@XmlRootElement
public class Customer {
private long id;
private String name;
public Customer() {}
public Customer(String name, long id) {
this.name = name;
this.id = id;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@XmlRootElement
public class Client extends Customer {
private String clientId;
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
}
Thank you.
Chaithanya.