Group
Extension

Matches 5

Mojo-Response-JSON-Path ( S/SC/SCESANO/Mojo-Response-JSON-Path-0.004.tar.gz, SCESANO, 2021; MetaCPAN )
Mojo-Response-JSON-Path/lib/Mojo/Response/JSON/Path.pm ( view source; MetaCPAN )
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
hift;

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

	    if (@_) {
		return JSON::Path->new($_[0])->value($orig->($self));
	    } else 
Mojo-Response-JSON-Path ( S/SC/SCESANO/Mojo-Response-JSON-Path-0.004.tar.gz, SCESANO, 2021; MetaCPAN )
Mojo-Response-JSON-Path/lib/Mojo/Response/JSON/Path.pod ( view source; MetaCPAN )

=head1 Mojo::Response::JSON::Path - use JSON::Path for searching JSON responses

=head2 SYNOPSIS

    use Mojo::Response::JSON::Path;
    use Mojo::UserAgent;

    my $ua = Mojo::UserAgent->new;

   
;

    my $json = $tx->res->json('$.entities');


=head2 DESCRIPTION

This module allows the use of an optional JSON Path expression to extract a specific value from a Mojo::Message via JSON::Path. 

=head2 FUNCTIONS

None

=head2 SEE ALSO

Related modules: L<Mojo::Message>, L<Mojo::JSON::Pointer>, L<JSON::Path>

=head2 AUTHORS

Simone Cesano 

=head2 COPYRIGHT AND LICENSE

This software is copyri
Mojo-Response-JSON-Path ( S/SC/SCESANO/Mojo-Response-JSON-Path-0.004.tar.gz, SCESANO, 2021; MetaCPAN )
Mojo-Response-JSON-Path/skunk/weirdo_server.pl ( view source; MetaCPAN )
in/env perl
use Mojolicious::Lite;

plugin 'Config';

get '/' => sub {
    my $c = shift;
    my $json = {
		"entities" => {
			       "Q100148272" => {
						"id" => "Q100148272",
						"sitelinks" =

						"type" => "item"
					       }
			      },
		"success" => 1
	       };

    $c->render(json => $json);
};

app->start;

__DATA__

@@ index.html.ep
% layout 'default';
% title 'Welcome';
<h1>Wel
Mojo-Response-JSON-Path ( S/SC/SCESANO/Mojo-Response-JSON-Path-0.004.tar.gz, SCESANO, 2021; MetaCPAN )
Mojo-Response-JSON-Path/skunk/weirdo_04.pl ( view source; MetaCPAN )
use Mojo::Util qw/dumper/;
use Mojo::Response::JSON::Path;
use Mojo::UserAgent;
use Time::HiRes qw/time/;

$\ = "\n"; $, = "\t";

my $ua = Mojo::UserAgent->new;

my $url = Mojo::URL->new("http://local
;
    my $json = $tx->res->json('$.entities');
    print dumper $json;
}

print time() - $start;

# print dumper $json;

# print dumper $tx->res->json('//title');

# my $u = Weirdo->new($json);

# pri
Mojo-Response-JSON-Path ( S/SC/SCESANO/Mojo-Response-JSON-Path-0.004.tar.gz, SCESANO, 2021; MetaCPAN )
Mojo-Response-JSON-Path/skunk/weirdo_03.pl ( view source; MetaCPAN )
ies&format=json&props=sitelinks&ids=Q19675&sitefilter=enwiki");

my $id = "Q100148272";
$url->query({ ids => $id });

$tx = $ua->get($url);

my $json = $tx->res->json();

print dumper $json;

print du
mper $tx->res->json('//title');

my $u = Weirdo->new($json);

print dumper $u->get('$.entities.Q100148272.sitelinks.enwiki.title');

print dumper $u->get('..title');



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