[libmagpie-perl] 01/30: add JSON deserializer

Jonas Smedegaard dr at jones.dk
Wed Dec 6 00:56:38 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/1.163200-1
in repository libmagpie-perl.

commit a5df70326a4cd6f3c82524814ef6e3cbee953c9a
Author: Chris Prather <chris at prather.org>
Date:   Fri Feb 21 20:41:39 2014 -0500

    add JSON deserializer
---
 lib/Magpie/Transformer/Input/JSON.pm | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/lib/Magpie/Transformer/Input/JSON.pm b/lib/Magpie/Transformer/Input/JSON.pm
new file mode 100644
index 0000000..fd909ed
--- /dev/null
+++ b/lib/Magpie/Transformer/Input/JSON.pm
@@ -0,0 +1,22 @@
+package Magpie::Transformer::Input::JSON;
+use Moose;
+extends qw(Magpie::Transformer);
+use Magpie::Constants;
+use JSON::Any;
+use Try::Tiny;
+
+__PACKAGE__->register_events(qw(transform));
+sub load_queue { return qw(transform) }
+
+sub transform {
+    my $self = shift;
+    my $ctxt = shift;
+    try {
+        $ctxt->{data} = JSON::Any->decode( $self->request->content );
+        return OK;
+    }
+    catch {
+        $self->set_error({status_code => 400, reason $_ });
+        return DECLINED
+    };
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmagpie-perl.git



More information about the Pkg-perl-cvs-commits mailing list