Hey there Tatu,

So after adding a provider class extending JacksonJaxbJsonProvider, I've
had success in producing JSONObjects over GET requests, but there's still
some trouble still with interpreting POSTed json in requests as JSONObject.
I was curious, should writing a custom MessageBodyReader still be necessary
with JsonOrgModule in use?


/* Application logic.. */

JacksonConfigFeature jsonJacksonFeature = new JacksonConfigFeature();
singletons.add(jsonJacksonFeature);


/* Jackson feature class.. */

@Provider
public final class JacksonConfigFeature implements Feature {

    @Override
    public boolean configure(final FeatureContext context) {
        context.register(JacksonConfigProvider.class);
        return true;
    }
}


/* Config provider class.. */

@Provider
@Produces(MediaType.APPLICATION_JSON)
public class JacksonConfigProvider extends JacksonJaxbJsonProvider  {

    private static ObjectMapper mapper = new ObjectMapper();
    static {
        mapper.registerModule(new JaxbAnnotationModule());
        mapper.registerModule(new JsonOrgModule());
     }

    public JacksonConfigProvider() {
        setMapper(mapper);
    }
}


/* Field in my DTO */
@XmlElement private JSONObject json;


I removed the implements ContextResolver<ObjectMapper> logic as it didn't
seem to be making a difference--is it necessary? Having one seems to always
result in JSONObject getting output as string--this was my original problem.


Cheers,
-Kean

On Mon, Nov 13, 2017 at 1:33 PM, Tatu Saloranta <[email protected]> wrote:

> Ok. If so it might make sense to first make sure that framework is
> using properly configured mapper.
> One way would be to create a simple stand-alone test with POJO,
> outside of framework (JAX-RS?).
> If I understood situation correctly it should just work. One thing I
> don't know is why value would be serialized
> as empty String -- I don't see how Jackson would ever produce that.
>
> Anyway: if stand-alone case fails as explained I'd like an issue filed
> for the module since this use case
> (reading JSON into org.json model; writing JSON out of org.json model)
> is what module was written for.
> So it should really "just work".
>
> -+ 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.

Reply via email to