cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin (Commented) (JIRA)" <>
Subject [jira] [Commented] (CXF-3861) Allow indentation of xml and json based on query parameter
Date Thu, 29 Dec 2011 13:33:31 GMT


Sergey Beryozkin commented on CXF-3861:

Hi, finally with Jettison 1.3.1 it is possible to optionally produce a formatted output.
However I don't see at the moment how we can support a generic 'indent' (or similar) query
because we have no control over the way say Jackson may do it or other XML providers (those
working with JAXP Source for ex).
The workaround is to register a custom output handler which can check whatever custom query
is used to request the optional indentation:

JAXBElementProvider and JSONProvider are driven by the JAXB Marshaller so by default they
check a Marshaller.JAXB_FORMATTED_OUTPUT property on the current message.

If needed we can also think of some other (internal) property name to be used by all the providers
that CXF ships and which produce XML or JSON, but at the moment I believe that using Marshaller.JAXB_FORMATTED_OUTPUT
to control the default JAXB & JSON providers is OK

Given that the above is not strictly a 'fix' for this issue, I'll close as it as won't fix,

see CXF-4000 for more info

> Allow indentation of xml and json based on query parameter 
> -----------------------------------------------------------
>                 Key: CXF-3861
>                 URL:
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>    Affects Versions: 2.4.3
>            Reporter: Jason Chaffee
> I would like to be able to force indent based on a query parameter so that we are not
indenting on every call, but only when we need to.  
> For example,
> http://localhost:8080/services/customer?indent=true
> It would be nice if indent would accept (yes|y|true|on).
> The code might look as follows for the JaxbElementProvider (not sure about Json).
> In the marshal method:
>         if (("on".equalsIgnoreCase(indent)) ||
>                 ("yes".equalsIgnoreCase(indent)) ||
>                 ("true".equalsIgnoreCase(indent))) {
>             ms.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
>         }

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message