volosied commented on code in PR #711:
URL: https://github.com/apache/myfaces/pull/711#discussion_r1594585268


##########
impl/src/main/java/org/apache/myfaces/push/Json.java:
##########
@@ -111,12 +112,45 @@ else if (object instanceof Class<?>)
         {
             encode(((Class<?>) object).getName(), builder);
         }
+        else if (object instanceof Record)
+        {
+            encodeRecord(object, builder);
+        }
         else
         {
             encodeBean(object, builder);
         }
     }
 
+    private static void encodeRecord(Object recordObject, StringBuilder 
builder) {
+
+        builder.append('{');
+        boolean fieldsFound = false;
+
+        for (Field field : recordObject.getClass().getDeclaredFields())
+        {
+            field.setAccessible(true);
+            fieldsFound = true;
+            String name = field.getName();
+            builder.append(name);
+            builder.append(':');
+            try {
+                encode(field.get(recordObject), builder);
+            } catch (IllegalArgumentException e) {
+                e.printStackTrace();
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }

Review Comment:
   I'm not sure what I should do with error handling here. 



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to