嗨我已經寫了下面的XML格式的簡單的「你好」的消息,它的工作原理,我的問題是如何變換下面的JSON格式的XML「你好」消息,什麼排序我應該進入哪些變化?Restful WebService使用澤西變換XML到JSON格式
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/hello")
public class Hello {
//Called if XML is request
@GET
@Produces(MediaType.TEXT_XML)
public String sayXMLHello() {
return "<?xml version=\"1.0\"?>" + "<hello> Hello, World!" + "</hello>";
}
//Called if JSON is request
很多選項,全部記錄在這裏:https://jersey.java.net/documentation/latest/media.html – samlewis