Using jersey jersey.java.net How do I set JSON as the default serialization instead of XML when there is no accept header or .xml suffix is in the URI?
You can assign the quality index to each media type in @Produces annotation. I.e.you can do the following to make Jersey prefer JSON if both XML and JSON are allowed:
@Produces({"application/json;qs=1", "application/xml;qs=.5"})
You should be able to set the @Produces
annotation to specify the return format like so:
@Produces( { "application/json" })
How come there is no accepts header?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With