[svn:p5ee] r9649 - p5ee/trunk/App-Widget-JSApp/lib/App/Widget

[email protected]
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
Author: spadkins
Date: Wed Jun 13 08:40:18 2007
New Revision: 9649

Modified:
   p5ee/trunk/App-Widget-JSApp/lib/App/Widget/JSApp.pm

Log:
serialization of attributes can now take deeply nested structures including hashrefs

Modified: p5ee/trunk/App-Widget-JSApp/lib/App/Widget/JSApp.pm
==============================================================================
--- p5ee/trunk/App-Widget-JSApp/lib/App/Widget/JSApp.pm	(original)
+++ p5ee/trunk/App-Widget-JSApp/lib/App/Widget/JSApp.pm	Wed Jun 13 08:40:18 2007
@@ -55,6 +55,23 @@
         $modified_value .= "]";
         $modified_value .= "\n   " if (!$oneline);
     }
+    elsif (ref($value) eq 'HASH') {
+        $modified_value .= "{";
+        foreach my $key (keys %$value) {
+            $val = $value->{$key};
+            if(ref($val) eq 'HASH') {
+                $modified_value .= "\"$key\" : ".$self->serialize_as_javascript($val);
+            }
+            else {
+                $modified_value .= "\"$key\" : \"".$val."\"";
+            }
+            $modified_value .= ",";
+        }
+
+        $modified_value =~ s/,$//;
+        $modified_value .= "}";
+    }
+
     $modified_value =~ s/,$//;
     return $modified_value;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.