IS it possible to encode the data in *iso*-*8859*-*1* ?
regards,
*
*
2011/6/7 João Rossa <joao.rossa_at_gmail.com>
> Yes that's the version im using, here's my ContextResolver, see if you see
> anything wrong:
>
> @Provider
> public class JacksonObjectMapperProvider implements
> ContextResolver<ObjectMapper> {
> //object mappers to be used for configurations
> private ObjectMapper defaultObjectMapper;
> private ObjectMapper listsObjectMapper;
>
> public JacksonObjectMapperProvider() {
> super();
> MyObjectMapperProvider();
> }
>
> public void MyObjectMapperProvider() {
> AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
> AnnotationIntrospector secondary = new JaxbAnnotationIntrospector();
> AnnotationIntrospector pair = new AnnotationIntrospector.Pair(primary,
> secondary);
>
> //object provider for default objects - show root name
> defaultObjectMapper = new ObjectMapper();
> defaultObjectMapper.configure(Feature.INDENT_OUTPUT, true);
> defaultObjectMapper.configure(Feature.WRAP_ROOT_VALUE, true);
>
> // make deserializer use JAXB annotations
>
> defaultObjectMapper.getDeserializationConfig().setAnnotationIntrospector(pair);
> // make serializer use JAXB annotations
>
> defaultObjectMapper.getSerializationConfig().setAnnotationIntrospector(pair);
>
>
> //object provider for list type objects - do not show root name
> listsObjectMapper= new ObjectMapper();
> listsObjectMapper.configure(Feature.INDENT_OUTPUT, true);
> listsObjectMapper.configure(Feature.WRAP_ROOT_VALUE, false);
>
> // make deserializer use JAXB annotations
>
> listsObjectMapper.getDeserializationConfig().setAnnotationIntrospector(pair);
> // make serializer use JAXB annotations
>
> listsObjectMapper.getSerializationConfig().setAnnotationIntrospector(pair);
> }
>
> public ObjectMapper getContext(Class<?> type) {
> if (type == ListWrapperWithMap.class) {
> return listsObjectMapper;
> } else {
> return defaultObjectMapper;
> }
>
> }
> }
>
>
> regards,
>
> On Tue, Jun 7, 2011 at 10:17 AM, Jakub Podlesak-2 [via Jersey] <
> ml-node+6448724-670819979-73314_at_n2.nabble.com> wrote:
>
>> Hi Maxrunner,
>>
>> Correct, you should be able to use different object mappers for different
>> types using Jersey 1.8-SNAPSHOT. See
>>
>> src/main/java/com/sun/jersey/samples/jacksonjsonprovider/MyObjectMapperProvider.java
>> from [1] for an example.
>>
>>
>> ~Jakub
>>
>> [1]
>> http://download.java.net/maven/2/com/sun/jersey/samples/jacksonjsonprovider/1.8-SNAPSHOT/jacksonjsonprovider-1.8-SNAPSHOT-project.zip
>>
>> On 06/06/2011 12:33 AM, Maxrunner wrote:
>>
>> Hi! been on vacations so sorry for not answering sooner. But im currently
>> using fixed 1.8 version that allows to use one or other mapper according to
>> type. Can you verify this?
>>
>> regards,
>>
>>
>> On Wed, Jun 1, 2011 at 8:04 AM, Jakub Podlesak-2 [via Jersey] <[hidden
>> email] <http://user/SendEmail.jtp?type=node&node=6443338&i=0>> wrote:
>>
>>> Hi,
>>>
>>> i just saw the super() and MyObjectMapperProvider() (this won't compile
>>> anyway, right;-)
>>> calls and wanted to make sure you understand, you can not have more than
>>> one ContextResolver<ObjectMapper> classes defined in your application,
>>> as more than one such resolvers would introduce an ambiguity.
>>>
>>> ~Jakub
>>>
>>> On 05/31/2011 11:47 AM, Maxrunner wrote:
>>>
>>> > Thanks jakub, its working fine now :). Still i didnt understand the
>>> second
>>> > correction you made to my contextresolver:
>>> >
>>> > "@Provider
>>> > public class JacksonObjectMapperProvider implements
>>> > ContextResolver<ObjectMapper>{
>>> >
>>> > private ObjectMapper defaultObjectMapper;
>>> > private ObjectMapper listsObjectMapper;
>>> >
>>> >
>>> > public JacksonObjectMapperProvider() {
>>> > super();
>>> > MyObjectMapperProvider();
>>> > }
>>> >
>>> > I do not know what the above means. Please note, that you should
>>> register
>>> > just one ContextResolver<ObjectMapper> instance, as Jackson will use
>>> only
>>> > the first one
>>> > if more that one such provider is found. To create different object
>>> mappers,
>>> > you should
>>> > use the getContext method bellow."
>>> >
>>> > Didnt understand this correction, can you elaborate?
>>> >
>>> > --
>>> > View this message in context:
>>> http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6422046.html
>>>
>>> > Sent from the Jersey mailing list archive at Nabble.com.
>>> >
>>>
>>>
>>>
>>> ------------------------------
>>> If you reply to this email, your message will be added to the
>>> discussion below:
>>>
>>> http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6425845.html
>>> To unsubscribe from how to rename XmlRootElement in JSON, click here.
>>>
>>
>>
>> ------------------------------
>> View this message in context: Re: how to rename XmlRootElement in JSON<http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6443338.html>
>>
>> Sent from the Jersey mailing list archive<http://jersey.576304.n2.nabble.com/>at Nabble.com.
>>
>>
>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6448724.html
>> To unsubscribe from how to rename XmlRootElement in JSON, click here<http://jersey.576304.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=6173292&code=am9hby5yb3NzYUBnbWFpbC5jb218NjE3MzI5MnwyMDYzODA1MDkw>.
>>
>>
>
>
--
View this message in context: http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6457220.html
Sent from the Jersey mailing list archive at Nabble.com.