users@jersey.java.net

Re: [Jersey] XmlJavaTypeAdapter when using JSON

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Sat, 06 Dec 2008 14:04:09 +0100

On Fri, Dec 05, 2008 at 02:06:38PM -0800, sarat.pediredla wrote:
>
> Sorry about this. I jumped the gun. The problem was more with how I was
> formatting the JSON as opposed to the XML.
>
> I am not using the Mapped configuration as follows for information.

The "not" is confusing me a bit. Have you meant "now"?
As based on the code, you *are* using the internal mapped configuration.

So everything is ok?

~Jakub

>
> public JsonContextResolver() throws Exception {
> Map props = new HashMap<String, Object>();
> props.put(JSONJAXBContext.JSON_NOTATION,
> JSONJAXBContext.JSONNotation.MAPPED);
> props.put(JSONJAXBContext.JSON_ROOT_UNWRAPPING, Boolean.TRUE);
> props.put(JSONJAXBContext.JSON_ARRAYS, new
> HashSet<String>(1){{add("objects");}});
> this.context = new JSONJAXBContext(types, props);
> }
>
>
> Paul Sandoz wrote:
> >
> > Hi,
> >
> > Did you verify if your DateAdapter is getting invoked or not when
> > unmarshalling from JSON?
> >
> > What are the JSON configuration options you are using?
> >
> > The default JSON configuration uses a specific JSON XMLStreamReader
> > implementation. It should not matter from JAXBs perspective in terms
> > of applying the XmlAdapter but may be it is a character decoding
> > issue... hard to say...
> >
> > If you are not using the default JSON configuration i would be curious
> > to know if it works for you using say the mapped jettison
> > configuration, which is using a different XMLStreamReader
> > implementation.
> >
> > If you have time sending a simple reproducible example would be very
> > helpful.
> >
> > Paul.
> >
> > On Dec 5, 2008, at 5:46 PM, sarat.pediredla wrote:
> >
> >>
> >> I have a custom DateAdapter which extends XmlAdapter to convert
> >> dates to and
> >> from ISO 8601 date format to use Ruby-like timestamps when XML and
> >> JSON is
> >> rendered and read.
> >>
> >> It all seems to work fine when "reading" data and the ISO 8601 date
> >> renders
> >> fine in both XML and JSON modes. However, when "posting" a new
> >> object, ISO
> >> 8601 dates only seem to work in XML and not JSON.
> >>
> >> I was wondering if this is because of the XmlJavaTypeAdapter and if
> >> this is
> >> not being triggered when unmarshalling JSON objects? Any views?
> >> --
> >> View this message in context:
> >> http://n2.nabble.com/XmlJavaTypeAdapter-when-using-JSON-tp1619181p1619181.html
> >> Sent from the Jersey mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> >> For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> > For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >
> >
> >
>
> --
> View this message in context: http://n2.nabble.com/XmlJavaTypeAdapter-when-using-JSON-tp1619181p1620323.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>