Hi

On Tue, Mar 8, 2011 at 12:41 AM, KARR, DAVID (ATTSI) <[email protected]> wrote:

> I'm using CXF 2.3.3 and Jackson 1.6.2.
>
> I asked about this on the Jackson list, but perhaps there's a different
> way to look at this from the JAXB or CXF point of view.
>
> I have some attributes defined as type "id" in my XML schema.  When CXF
> renders this as XML, it just renders the ID value, which is what I need.
> When this is rendered as JSON, it appears Jackson is trying to be a
> little more intelligent than I would have liked.  Instead of just
> rendering the ID value, it's rendering the object the ID value refers
> to.  I can see this would be useful in some circumstances, but it's not
> useful for how we're using it.  I could punt and just change my ID
> attributes to "string", but I'd prefer not to do that.
>
>
You might need to inject the JacksonProvider with your own custom
ObjectMapper which (with ObjectCodec) seems to be responsible for the actual
mapping, use "mapper" property:

http://grepcode.com/file/repo1.maven.org/maven2/org.codehaus.jackson/jackson-jaxrs/1.2.0/org/codehaus/jackson/jaxrs/JacksonJsonProvider.java

and

http://jackson.codehaus.org/1.2.0/javadoc/org/codehaus/jackson/map/ObjectMapper.html

But if you didn't get a similar advice on the Jackson list then may be it
won't work after all...

How would I configure the Jackson interface in CXF so that ID attributes
> are rendered as the value, not as the object it refers to?
>
>
In CXF we can only control the Jettison-driven output, example, you could've
configured the provider for it to drop certain elements easily. I'm not
advocating it as obviously you had the reason for going with Jackson


> I suppose it's likely that I'm going to have to implement a JAXB binding
> file that specifies for particular attributes that are of type ID, to
> generate a specific annotation that will cause it to be rendered as a
> raw value, instead of an object.  Are there some examples of doing this
> somewhere?  I briefly read about the "annox" plugin.  Is that the way to
> go here?
>

I hope you can avoid going that way :-)
Cheers, Sergey

-- 
Sergey Beryozkin

Application Integration Division of Talend <http://www.talend.com>
http://sberyozkin.blogspot.com

Reply via email to