THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
| Supported | Media Types | Entity |
---|---|---|---|
Read | Yes | application/json , application/javascript | JAXB object, |
Write | Yes | application/json , application/javascript | JAXB object, |
Examples
TBD
Producing and Consuming JSON
TBD
Code Block |
---|
@GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public JSONObject postJSON(JSONObject requestJSON) { String property = requestJSON.getString("property"); JSONObject jobj = new JSONObject(); return jobj; } /* Book is a JAXB annotated class */ @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Book postJSONBook(Book requestBookEntity) { String title = requestBookEntity.getTitle(); /* other code */ Book response = new Book(); return response; } |
...
| Supported | Media Types | Entity |
---|---|---|---|
Read | Yes | application/json | JAXB object |
Write | Yes | application/json | JAXB object |
Example
TBD
Enabling Reading
TBD
Code Block |
---|
public class MyApp extends Application { public Set getClasses() { Set s = new HashSet(); s.add(MyResource.class); return s; } public Set<Object> getSingletons() { Set s = new HashSet(); JettisonJAXBProvider jaxbProvider = new JettisonJAXBProvider(); jaxbProvider.setUseAsReader(true); return s; } } |
Producing and Consuming JSON
TBD
Code Block |
---|
/* Book is a JAXB annotated class */ @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Book postJSONBook(Book requestBookEntity) { String title = requestBookEntity.getTitle(); /* other code */ Book response = new Book(); return response; } |
...