Move JsonItemWriter to o.a.s.commons.json
-----------------------------------------

                 Key: SLING-201
                 URL: https://issues.apache.org/jira/browse/SLING-201
             Project: Sling
          Issue Type: Improvement
            Reporter: Bertrand Delacretaz
            Priority: Minor


Currently we have 3 JsonItemWriters:

./launchpad/launchpad-servlets/src/main/java/org/apache/sling/launchpad/renderers/JsonItemWriter.java
./microsling/microsling-core/src/main/java/org/apache/sling/microsling/helpers/json/JsonItemWriter.java
./sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/JsonItemWriter.java

The microsling one can be left alone as that'll go away soon anyway, but the 
other ones should move to the o.a.s.commons.json module.

Also, the writer doesn't handle multivalued properties correctly, needs this 
patch:

Index: 
sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/JsonItemWriter.java
===================================================================
--- 
sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/JsonItemWriter.java
 (revision 615066)
+++ 
sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/JsonItemWriter.java
 (working copy)
@@ -92,6 +92,7 @@
            if (!prop.getDefinition().isMultiple()) {
                writeProperty(w, currentRecursionLevel, prop);
            } else {
+                w.key(prop.getName());
                w.array();
                for(Value v : prop.getValues()) {
                    w.value(convertValue(v));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to