dev@jersey.java.net

Re: [Jersey] JSONP wrapper for Jackson (JSONPObject.java)

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 08 Feb 2010 13:31:12 +0100

Hi Tatu,

Do you have a link to the source of:

   org.codehaus.jackson.map.util.JSONPObject

?

Do you know if we can retain backwards compatibility with Jersey's
JSONWthPadding class by leveraging JSONPObject? For example, if the
Jackson JAX-RS providers are registered Jackson JSON with padding will
be utilized, otherwise fallback to the Jersey approach will be utilized.

Jersey's JSONWthPadding is a bit special because JSON with padding is
only used if an appropriate media type is acceptable i.e. it could be
used with say application/xml, application/json or say application/
javascript and only the latter will result in padding.

Also can the Jackson processing escape JSON text (that might be say
HTML content)?

Paul.

On Feb 8, 2010, at 1:05 AM, Tatu Saloranta wrote:

> Ok, as per Jackson issue
> [http://jira.codehaus.org/browse/JACKSON-234], I thought it would
> actually be nice to have a wrapper a wrapper object that Jackson knows
> how to serialize as JSONP wrapping. I am hoping this would work well
> with Jersey JSONP integration.
> But as additional bonus, it will be possible to also then do wrapping
> without framework having to explicitly enable/disable it.
>
> Amount of code that was needed was trivial (for once I am happy I
> added JsonGenerator.writeRaw(), which works nicely here), so let me
> know if you have improvement ideas.
>
> Jakub, Paul: do you think this would work wrt. earlier discussion on
> how to handle JSONP integration? I added code in core mapper module
> since it seemed general-enough-purpose to warrant inclusion.
>
> Addition will be in version 1.5.0, since I don't add new functionality
> in patch releases (even safe ones like this would be), because of
> confusion it could happen (1.4.3 having JSONP support, 1.4.2 not --
> patch releases should be interchangeable minus bug fixes). So it might
> take a while to get it used by Jersey. But I am hoping basic idea
> would work.
>
> -+ Tatu +-
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>