[
https://issues.apache.org/jira/browse/SLING-3776?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14070079#comment-14070079
]
Bertrand Delacretaz commented on SLING-3776:
--------------------------------------------
Thanks for the added tests at https://github.com/apache/sling/pull/23
The more I look at this the more I think it belongs to JSONObject - we already
have JSON formatting code scattered around, we shouldn't make that worse.
Instead of having the formatting code in JsonRendererServlet I suggest adding
something like this to JSONObject, with some tests in that module:
{code}
// a new class
public class JSONStringOptions {
final int perLevelIndent;
final int initialIndent;
boolean useArraysForChildObjects:
//...with a suitable constructor...
}
public class JSONObject {
...
public String toString(JSONStringOptions opt) {
// ...dispatch to the existing formatting methods +
// the new one with harray support
}
}
{code}
WDYT?
> JsonRendererServlet should provide a way to list children as an array
> ---------------------------------------------------------------------
>
> Key: SLING-3776
> URL: https://issues.apache.org/jira/browse/SLING-3776
> Project: Sling
> Issue Type: Improvement
> Components: Servlets
> Affects Versions: Servlets Get 2.1.8
> Reporter: Damien Antipa
>
> The default JSON renderer prints all children of a node as another key-value
> attribute. But browsers do not respect the order printed in the response of
> object attributes (since the standard does not describe this).
> In a lot of cases I continue writing my own servlets to print the children as
> a json array which respects the order. Imo the default renderer should
> provide a selector to change the output and print children in an array.
> PR: https://github.com/apache/sling/pull/23
--
This message was sent by Atlassian JIRA
(v6.2#6252)