Hi

Hi,

Thank you for the prompt reply.

Jettison-Mapped notations

Isn't it what the default JSONProvider we ship supports ? I thought it did...Or 
am I wrong ?

default JSONProvider supports Mapped notation which is slightly different from  
Jettison-Mapped notation.

I chatted with Dejan and he was not aware of a 'Jettison-Mapped' convention, perhaps some other library which sits on top of Jettison offers it ?

as far as BudgerFish is concerned : I'll do a quick update to JSONProvider to support it too in time for 2.1.5; Jettison 1.1 also supports type converters so JSONProviders will allow injecting them too

Also, as far as that Client/Consumer issue is concerned : you can probably just use jaxb.index (starting from 2.2.4) instead of @XmlSeeAlso and friends

thanks, Sergey



Thank you.
Chaithanya.

----- Original Message ----- From: "Sergey Beryozkin" <sbery...@progress.com>
To: <dev@cxf.apache.org>
Sent: Thursday, October 29, 2009 3:37 PM
Subject: Re: Some queries regarding JSON support in cxf-2.2.4


Hi,

Issue1.
There's a custom BadgerFish provider available in the system test area :

http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BadgerFishProvider.java

So please feel free to copy the source and use it as a custom provider in your 
own project.
(I'm still hoping someone who provided that patch awhile back will get back 
with few more patches and become a committer :-)).

Jettison-Mapped notations

Isn't it what the default JSONProvider we ship supports ? I thought it did...Or 
am I wrong ?

Issue2.
I'm not sure how Jersey JSON detects that subclasses have to be handled in some 
cases, but by adding
@XmlSeeAlso(Client.class) to Customer.class (perhaps adding @XmlElements(Client.class, Customer.class) to the List<Customer> field would have the same result) produces :

{"myObject":{"list":[{"id":111,"name":"aaa"},{"@xsi.type":"client","id":10000000,"name":"firstClient","clientId":9999999}]}}

Note "@xsi.type, I think it's actually better than @type because using @type would interfere with attributes called 'type' (in cases when classes have been generated from schema types containing attributes such as 'type') but which have nothing to do with class hierarchies, but have some domina-specific meaning

cheers, Sergey





----- Original Message ----- From: "Chaitanya" <chaitan...@pramati.com>
To: "cxf_dev" <dev@cxf.apache.org>
Sent: Thursday, October 29, 2009 8:39 AM
Subject: Some queries regarding JSON support in cxf-2.2.4


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.


Reply via email to