> But why not use POJOs themselves? Or can you not add annotations
> if/when needed? Maybe you start with non-object data?
I do have objects, however they are not beans, and they come from
another API which I don't want to clutter with annotations for JSON
serialization, as that should be orthogonal to the original API. I'll
need to try out what Jackson offers here.
> It shouldn't, if classes you use are beans.
That's the problem - I don't have beans. E.g. some method returns an
XhiveDriverIf, which is the actual object representing my resource.
It's a typical Java API with some 50 methods, of which I want to
expose ~5 things: one thing is a Map<String,Number> (statistics), one
thing is a List of sub-objects which in turn have three fields I'm
interested in. Some of the fields have to be mangled, e.g. turned into
proper URIs through UriInfo to be a nice HATEOAS citizen.
> Going back to basics: do you start by just explicitly building the
> response? And if so, what is the source data?
See above, I have objects that represent a superset of the information
I want to expose, but I need to extract a partial subset. I don't see
how this will work out of the box, so I either need to build my JSON
manually, build special objects that only contain the relevant fields,
or write some configuration/instructions for a serializer. Just
returning e.g. the XhiveDriverIf will probably not work.
Thanks for your insights!
Martin