Class JsonRenderer
java.lang.Object
org.apache.sling.servlets.get.impl.helpers.JsonRenderer
- All Implemented Interfaces:
Renderer
The
JsonRendererServlet
renders the current resource in JSON
on behalf of the DefaultGetServlet
.-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Selector that causes hierarchy to be rendered as arrays instead of child objects - useful to preserve the order of those child objectsstatic final int
How much to indent in tidy modestatic final String
Recursion level selector that means "all levels"static final String
Selector that means "pretty-print the output -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected int
Get recursion level from selectors. as per SLING-167: the last selector, if present, gives the recursion level.protected boolean
hasSelector
(SlingHttpServletRequest req, String selectorToCheck) Checks if the provided request contains a certain selector.protected boolean
True if our request wants the "tidy" pretty-printed formatvoid
-
Field Details
-
INFINITY
Recursion level selector that means "all levels"- See Also:
-
TIDY
Selector that means "pretty-print the output- See Also:
-
HARRAY
Selector that causes hierarchy to be rendered as arrays instead of child objects - useful to preserve the order of those child objects- See Also:
-
INDENT_SPACES
public static final int INDENT_SPACESHow much to indent in tidy mode- See Also:
-
-
Constructor Details
-
JsonRenderer
public JsonRenderer(long maximumResults, boolean ecmaSupport)
-
-
Method Details
-
render
- Specified by:
render
in interfaceRenderer
- Throws:
IOException
-
getMaxRecursionLevel
Get recursion level from selectors. as per SLING-167: the last selector, if present, gives the recursion level.- Parameters:
req
- the request- Returns:
- the recursion level
- Throws:
IllegalArgumentException
- if the detected selector is not a number
-
hasSelector
Checks if the provided request contains a certain selector.- Parameters:
req
- the requestselectorToCheck
- the selector- Returns:
true
if the selector is present,false
otherwise
-
isTidy
True if our request wants the "tidy" pretty-printed format- Parameters:
req
- the request- Returns:
true
if the request contains theTIDY
selector,false
otherwise
-