JSArrayParser: Add JSJSONArrayParser as new (and preferred) method to parse JSON
[videosite.git] / videosite / JSJSONArrayParser.pm
diff --git a/videosite/JSJSONArrayParser.pm b/videosite/JSJSONArrayParser.pm
new file mode 100644 (file)
index 0000000..052e325
--- /dev/null
@@ -0,0 +1,30 @@
+#
+# A helper class for parsing textual JS hashes into perl 
+# hashes
+#
+# This parser is based on the perl JSON module
+#
+
+package videosite::JSJSONArrayParser;
+
+use videosite::JSArrayParser;
+use JSON;
+@ISA = qw(videosite::JSArrayParser);
+
+use strict;
+
+sub new {
+    my $class = shift;
+    my $self = $class->SUPER::new();
+
+    return bless($self, $class);
+}
+
+sub parse {
+    my $self = shift;
+    my $s = shift;
+
+    return decode_json($s);
+}
+
+1;