Hi -
We have some JSON format services created, which are all working well,
based on the json-from-jaxb example.
Is there anyway to get the JSON format string of a Collection<?> type
using the ContextResolver injected via @Context? We can do it with JAXB
types, but I'm trying to figure out if we can avoid wrapping the
collections.
Background:
We have some occasions where we need to "manually" generate JSON format
strings and use a String type result on a resource method, which works
fine when we modify the types in our JAXBContextResolver class.
We would like to be able to also "manually" generate JSON format strings
from Collection<?> types, but I'm not sure if this is possible?
The method:
JAXBContext getContext(Class<?> objectType)
Only receives type info for the collection instance, not the type of its
contents.
Any ideas on a way around this?
Our alternative will be to not rely on JAXB config to generate JSON
format in these cases, which is less than ideal.
Our use case for doing this is that we have some JSP templates that
serve HTML + javascript, and the javascript uses some AJAX style widgets
that consume JSON data. In some cases, it is best for us to serve all
the content at one time, where the JSON data is embedded into the HTML
as a static string in JSON format.
Thanks for any ideas!
Tyson