On Wed, Nov 15, 2017 at 6:43 PM, Kean Erickson <[email protected]> wrote:
> Thanks for all your help, I finally got it working both ways. Counter to
> what other guides have said, having a ContextMapper was not necessary, nor
> was having a class  "JacksonConfigFeature implements Feature".
>
> Adding this singleton to my application (with extends
> JacksonJaxbJsonProvider and consumes + produces) was all that was needed.
>
> @Provider
> @Consumes(MediaType.APPLICATION_JSON)
> @Produces(MediaType.APPLICATION_JSON)
> public class JacksonConfigProvider extends JacksonJaxbJsonProvider {
>
>     private final static ObjectMapper mapper =
>                     new ObjectMapper()
>                     .registerModule(new JsonOrgModule())
>                     .registerModule(new JaxbAnnotationModule());
>
>     JacksonConfigProvider() {
>         super(mapper, JacksonConfigProvider.DEFAULT_ANNOTATIONS);
>     }
> }
>
> No jersey-specific junk needed. I'm relieved, this was really difficult due
> to metric tonnes of misinformation online. Thanks again!

Thank you for sharing this: it makes sense to me.

Yes, so much old/mis-information. And sometimes frameworks
adding wrapping around features like Jackson which tends to obfuscate
more straight-forward usage.

-+ Tatu +-

>
>
> On Wed, Nov 15, 2017 at 3:53 PM, Tatu Saloranta <[email protected]> wrote:
>>
>> On Wed, Nov 15, 2017 at 3:22 PM, Kean Erickson <[email protected]>
>> wrote:
>> > Thanks you, Tatu. Unless I am misunderstanding, it does seem that my
>> > ObjectMapper with JsonOrgModule() is being used, given that I can print
>> > JSON
>> > properly in GET requests.
>> > Is it necessary to have a provider class for the ObjectMapper which
>> > implements ContextResolver<ObjectMapper>? Or would that incur added
>> > overhead
>> > as you mentioned here?
>> > https://github.com/FasterXML/jackson-jaxrs-providers/issues/86
>>
>> I don't think your registering provider makes a big difference, as
>> long as you make sure to return singleton
>> mapper instance -- that is, if and when it is called for every request
>> make sure not to have to construct
>> new mapper every time.
>>
>> As to whether that is necessary I honestly do not know. Maybe someone
>> else can help here.
>>
>> -+ Tatu +-
>>
>> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "jackson-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to