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 +-


On Mon, Nov 13, 2017 at 11:12 AM, Kean Erickson <[email protected]> wrote:
> Hi Tatu, thanks for getting back to me. I do have the jaxb-annotations
> module, currently, as well as jackson-datatype-json-org and
> jackson-databind. Here's a stub of my application config:
>
>     public class ApplicationConfig extends Application {
>         private final Set<Class<?>> classes;
>
>         public ApplicationConfig() {
>
>             HashSet<Class<?>> c = new HashSet<>();
>             c.add(JacksonJsonProvider.class);
>             c.add(JacksonJaxbJsonProvider.class);
>             c.add(ObjectMapperProvider.class);
>             classes = Collections.unmodifiableSet(c);
>
>             // ...
>         }
>
>
>         @Provider
>         public static class ObjectMapperProvider implements
> ContextResolver<ObjectMapper> {
>
>             private final ObjectMapper mapper;
>
>             public ObjectMapperProvider() {
>                 mapper = new ObjectMapper();
>                 mapper.registerModule(new JsonOrgModule());
>             }
>
>             @Override
>             public ObjectMapper getContext(Class<?> type) {
>                 return mapper;
>             }
>         }
>     }
>
>
> And then in my @XmlRootElement-annotated class, I have a member..
>
>     @XmlElement private JSONObject obj;
>
> This item always comes back as "" in any JSON response, rather than as a
> json object with populated contents. Using @JsonProperty on the JSONObject
> has the same result. JSONObject is what I use in the rest of the
> application, so I'm trying to avoid having to do any conversion with
> Jackson's JsonNode or similar.
>
>
> Cheers
>
> On Friday, November 10, 2017 at 1:21:26 PM UTC-8, Tatu Saloranta wrote:
>>
>> On Thu, Nov 9, 2017 at 4:17 PM, Kean Erickson <[email protected]> wrote:
>> > Currently, any @XmlElement JSONObjects in an @XmlRootElement class iare
>> > sent
>> > out as a blank string. Being able to simply use a json object rather
>> > than
>> > package my existing json into a string (handling for curlies rather than
>> > a
>> > blank string as output, yada yada) would clean up my code rather nicely.
>> >
>> > Maybe it's naiive to say, but all examples of implementing this
>> > marshaling
>> > myself (based on the two other threads here about this) looks like a
>> > bunch
>> > of unsightly cruft / plumbing that would stick out like a sore thumb in
>> > my
>> > codebase.  Is there any way that JSONObjects could be supported as
>> > output,
>> > or would something like that never even be considered for the roadmap?
>> > Thanks!
>>
>>
>> If you mean whether you could use module with Java classes like:
>>
>> public class Stuff {
>>    @JacksonAnnotation // placeholder for any annotation Jackson knows
>>    public JSONObject extra;
>> }
>>
>> yes, that is expected usage. Ont thing to note is that `@XmlElement`
>> is JAXB annotation, and you need another module
>> (`jackson-module-jaxb-annotations`)
>> to support that one (if you used `@JsonProperty` instead that would
>> work without additional modules as it is Jackson native)
>>
>> If I misunderstood the question, could you add a sample of how you are
>> trying to use the module?
>>
>> -+ 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