strict;
use Mojo::Autobox;
# "site.com\n"
'{"html": "<a href=\"http://site.com\"></a>"}'
->json('/html')
->dom->at('a')->{href}
->url->host
->byte_stream->say;
=head1 DESCRIPTION
Usi
package Mojo::Autobox::Hash;
use Mojo::Base -strict;
sub json {
require Mojo::JSON;
Mojo::JSON::encode_json(shift);
}
*j = \&json;
1;
=head1 NAME
Mojo::Autobox::Hash - Autobox hash methods f
ld'}->json;
=head1 DESCRIPTION
Hash methods for L<Mojo::Autobox>. These also apply to hash references.
=head1 METHODS
=head2 json
Serializes the invocant hash using L<Mojo::JSON/encode_json> and
returns the result.
=head2 j
An alias for L</json>.
}
sub json {
require Mojo::JSON;
require Mojo::JSON::Pointer;
my $data = Mojo::JSON::decode_json(shift);
return @_ ? Mojo::JSON::Pointer->new($data)->get(shift) : $data;
}
*j = \&json;
sub
e_stream->trim;
# "Text"
'<p>Text</p>'->dom->at('p')->text;
# "world"
'{"hello": "world"}'->json->{hello};
# "anchor"
'http://mysite.com/path#anchor'->url->fragment;
=head1 DESCRIPTION
Str
ead2 json
Parses the invocant string as JSON using L<Mojo::JSON/decode_json> and returns the result.
Optionally takes a JSON pointer used to delve into the resulting structure using L<Mojo::JSON::Poi
Mojo::Collection->new(@{shift()});
}
*c = \&collection;
sub json {
require Mojo::JSON;
Mojo::JSON::encode_json(shift);
}
*j = \&json;
1;
=head1 NAME
Mojo::Autobox::Array - Autobox array meth
x;
# "a"
[qw/a b c/]->collection->first;
# '["x", "y", "z"]'
@array = (qw/x y z/);
@array->json;
=head1 DESCRIPTION
Array methods for L<Mojo::Autobox>. These methods also apply to array refer
Collection>, contructed from the elements of the invocant array.
=head2 json
Serializes the invocant array using L<Mojo::JSON/encode_json> and returns the result.
=head2 j
An alias for L</json>.
strict;
use Mojo::Autobox;
# "site.com\n"
'{"html": "<a href=\"http://site.com\"></a>"}'
->json('/html')
->dom->at('a')->{href}
->url->host
->byte_stream->say;
=head1 DESCRIPTION
Usi