rmannibucau commented on a change in pull request #38: JOHNZON-205: add support 
for arrays in toStructure
URL: https://github.com/apache/johnzon/pull/38#discussion_r270668041
 
 

 ##########
 File path: johnzon-mapper/src/main/java/org/apache/johnzon/mapper/Mapper.java
 ##########
 @@ -146,12 +146,31 @@ public JsonValue toStructure(final Object object) {
         if (BigInteger.class.isInstance(object)) {
             return provider.createValue(BigInteger.class.cast(object));
         }
+
         final JsonObjectGenerator objectGenerator = new 
JsonObjectGenerator(builderFactory);
-        writeObject(object, objectGenerator, null,
-                isDeduplicateObjects(object.getClass()) ? new 
JsonPointerTracker(null, "/") : null);
+        if (object.getClass().isArray()) {
+            writeObject(objectToList(object), objectGenerator, null,
+                    isDeduplicateObjects(object.getClass()) ? new 
JsonPointerTracker(null, "/") : null);
+        } else {
+            writeObject(object, objectGenerator, null,
+                    isDeduplicateObjects(object.getClass()) ? new 
JsonPointerTracker(null, "/") : null);
+        }
         return objectGenerator.getResult();
     }
 
+    private List objectToList(Object object) {
 
 Review comment:
   We already have that kind of logic, therefore question is: cant we reuse it 
and avoid one array and list allocation OR at least reuse the existing code?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to