You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Sergey Beryozkin (Commented) (JIRA)" <ji...@apache.org> on 2011/12/29 14:33:31 UTC

[jira] [Commented] (CXF-3861) Allow indentation of xml and json based on query parameter

    [ https://issues.apache.org/jira/browse/CXF-3861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13177169#comment-13177169 ] 

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:

http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/FormatResponseHandler.java

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: https://issues.apache.org/jira/browse/CXF-3861
>             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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira