Group
Extension

Mojo-Response-JSON-Path/lib/Mojo/Response/JSON/Path.pm

package Mojo::Response::JSON::Path;

# ABSTRACT: use JSON::Path for searching JSON responses

use Class::Method::Modifiers qw/install_modifier/;
use Mojo::Message;
use JSON::Path;

sub import {
    my $class = shift;

    install_modifier "Mojo::Message", 'around', 'json',
	sub {
	    my $orig = shift;
	    my $self = shift;

	    if (@_) {
		return JSON::Path->new($_[0])->value($orig->($self));
	    } else {
		return $orig->($self);
	    }
	};
}

1



Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.