about summary refs log tree commit diff
path: root/lib/Net/HTTP/API/Parser
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-07-16 16:10:41 +0200
committerfranck cuny <franck@lumberjaph.net>2010-07-16 16:10:41 +0200
commite97449eaa8bd3a408763057f9ca2253d93e2a3d0 (patch)
tree4fd0dc6ed899efe361e314adfc913b9aa6b0a1a4 /lib/Net/HTTP/API/Parser
parentcheck if auth_method is declared (diff)
downloadnet-http-api-e97449eaa8bd3a408763057f9ca2253d93e2a3d0.tar.gz
rename from mx::net::api to net::http::api
Diffstat (limited to 'lib/Net/HTTP/API/Parser')
-rw-r--r--lib/Net/HTTP/API/Parser/JSON.pm23
-rw-r--r--lib/Net/HTTP/API/Parser/XML.pm30
-rw-r--r--lib/Net/HTTP/API/Parser/YAML.pm23
3 files changed, 76 insertions, 0 deletions
diff --git a/lib/Net/HTTP/API/Parser/JSON.pm b/lib/Net/HTTP/API/Parser/JSON.pm
new file mode 100644
index 0000000..be8b30e
--- /dev/null
+++ b/lib/Net/HTTP/API/Parser/JSON.pm
@@ -0,0 +1,23 @@
+package Net::HTTP::API::Parser::JSON;
+
+# ABSTRACT: Parse JSON
+
+use JSON;
+use Moose;
+extends 'Net::HTTP::API::Parser';
+
+sub encode {
+    my ($self, $content) = @_;
+    return JSON::encode_json($content);
+}
+
+sub decode {
+    my ($self, $content) = @_;
+    return JSON::decode_json($content);
+}
+
+1;
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
diff --git a/lib/Net/HTTP/API/Parser/XML.pm b/lib/Net/HTTP/API/Parser/XML.pm
new file mode 100644
index 0000000..aaedfcd
--- /dev/null
+++ b/lib/Net/HTTP/API/Parser/XML.pm
@@ -0,0 +1,30 @@
+package Net::HTTP::API::Parser::XML;
+
+# ABSTRACT: Parse XML result
+
+use XML::Simple;
+use Moose;
+extends 'Net::HTTP::API::Parser';
+
+has _xml_parser => (
+    is      => 'rw',
+    isa     => 'XML::Simple',
+    lazy    => 1,
+    default => sub { XML::SImple->new(ForceArray => 0) }
+);
+
+sub encode {
+    my ($self, $content) = @_;
+    return $self->_xml_parser->XMLin($content);
+}
+
+sub decode {
+    my ($self, $content) = @_;
+    return $self->_xml_parser->XMLout($content);
+}
+
+1;
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
diff --git a/lib/Net/HTTP/API/Parser/YAML.pm b/lib/Net/HTTP/API/Parser/YAML.pm
new file mode 100644
index 0000000..f18593a
--- /dev/null
+++ b/lib/Net/HTTP/API/Parser/YAML.pm
@@ -0,0 +1,23 @@
+package Net::HTTP::API::Parser::YAML;
+
+# ABSTRACT: Parse YAML
+
+use YAML::Syck;
+use Moose;
+extends 'Net::HTTP::API::Parser';
+
+sub encode {
+    my ($self, $content) = @_;
+    return Dump($content);
+}
+
+sub decode {
+    my ($self, $content) = @_;
+    return Load($content);
+}
+
+1;
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION