java - How Can I Convert JAXB to JSON? -


i need create web service front-end xml-based web service returns jaxb object. front-end needs return restful format. there way convert json? have jackson-mapper-asl , jackson-core-asl in class path.

as simple test, return bean of book, , gets output json, jaxb object (delivery schedule) stays in xml format.

import org.springframework.beans.factory.annotation.autowired; import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.pathvariable; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.bind.annotation.responsebody;  @controller public class dswliclient {      @autowired     private deliveryschedulews wliservice;     private bookservice bs;      @requestmapping(value = "/dsdetails/{ds-number}", method = requestmethod.get)     public @responsebody     deliveryschedule getdsdetails(@pathvariable("ds-number") string dsnumber) {         deliveryscheduleresponse dsdetails = wliservice.getdeliveryschedulewssoap().getdsdetails(dsnumber);         deliveryschedule deliveryschedule = dsdetails.getdeliveryschedule();         return deliveryschedule;     }       @requestmapping(value = "/bookdetails/{isbn-number}", method = requestmethod.get)     public @responsebody     book getbookdetails(@pathvariable("isbn-number") string isbnnumber) {         bs = new bookservice();         book b = bs.getbookbyisbn(isbnnumber);         system.out.println(b.getauthor());         return b;     }   } 

can show configuration file (xml or class)?

also assume using httpmessageconverter (http://www.ibm.com/developerworks/web/library/wa-restful/) class , not contentnegotiatingviewresolver.

that dead easy, of time because forget add required configuration "mvc:annotation-driven"

in case use content negotiation view example great http://www.mkyong.com/spring-mvc/spring-3-mvc-contentnegotiatingviewresolver-example/


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -