Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
Just a thought; after using Jackson on some JAXRS beans in RestMQ, things look great...
$ curl -Haccept:application/json http://localhost:8080/ {"resources":[{"name":"queues","uri":"/queues"},{"name":"topics","uri":"/topics"}]}
Though it might be nice to enable pretty printing somehow (the JacksonJsonProvider could be injected with an optional HTTP query argument maybe?) so you could do something like this...
$ curl -Haccept:application/json http://localhost:8080/?pretty=true { "resources":[ {"name":"queues", "uri":"/queues"}, {"name":"topics", "uri":"/topics"}] }
without having to add the processing of the query arguments to every method which returns JSON objects etc
It is already possible to enable pretty-printing (I do that myself for test deployments); for this you need to configure ObjectMapper object. And that can be done either by registering Jackson with properly config'ed instance, a la:
(when using sub-class of Application)
—
@Override
public Set<Object> getSingletons()
{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
singletons.add(new JacksonJsonProvider(mapper));
}
—
or by injecting ObjectMapper via provider (if you don't control adding of JacksonJsonProvider)
Would these work? They need to be added to FAQ at any rate.
Also: if you can think of more convenient ways to do this (I know you have bit more experience as a Jersey user than I do, so it seems likely!), those can definitely be added. Current provider is just the first stab at trying to provider something useful.