You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Juerg Meier (Jira)" <ji...@apache.org> on 2020/05/18 17:57:00 UTC
[jira] [Created] (SLING-9455) JsonItemWriter
Juerg Meier created SLING-9455:
----------------------------------
Summary: JsonItemWriter
Key: SLING-9455
URL: https://issues.apache.org/jira/browse/SLING-9455
Project: Sling
Issue Type: New Feature
Components: Commons
Affects Versions: Commons JSON 2.0.18
Environment: Sling Starter
Reporter: Juerg Meier
Sling 8 came with an org.apache.sling.commons.json bundle/package. The .jcr sub-package contained two classes:
* JsonItemWriter
* JsonJcrNode
(javadoc [here|https://sling.apache.org/apidocs/sling8/org/apache/sling/commons/json/jcr/package-summary.html)
These two classes allowed for serializing a sling resource to well formated JSON and a JCR node to an org.apache.sling.commons.json.JSONObject, respectively.
For legal reasons, this package was discontinued and is not present anymore in later versions, including the current Sling 11 version.
Consequently, Sling 11 lacks of a simple yet application-controllable way to serialize a Resource directly to a JSON string. However, many API calls, used in particular by client-side Javascript frameworks (e.g. for Single Page Apps), rely heavily on JSON.
Hence, it would be desirable to have the Sling 8 JSON package (or similar) back in Sling. The following functionality should be present to have a flexible JSON generator available within Sling:
* direct conversion of Nodes/Resources to a String containing JSON
* application control of node recursion levels (child nodes as JSON objects)
* should allow to set a negative list of properties (those not to render in the output)
* proper rendering of all JCR property types to JSON including
** date format definition (default = ISO8601)
** multi-values support (as JSON arrays)
** proper escaping of special chars in Strings
* adding additional string/value pairs by the application (i.e. not originating from the dumped Resource)
See also thread on the sling-users mailing list starting 12 May 2020/"Resource to json serializing"
--
This message was sent by Atlassian Jira
(v8.3.4#803005)