Hello Sergey.

Yes, I got json from Yandex Maps API. 
With wget and curl it's working, but I need to realize it with UserAgent 
get() method. 
I suppose that it's a bug of latest versions. Cause in 5.50 everything 
works ok. So let's wait maintainer's answer.

суббота, 27 июня 2015 г., 12:53:27 UTC+3 пользователь Sergey Andreev 
написал:
>
> Did you got json from another app? Try curl or wget same url, for me your 
> script return json.
> On Jun 27, 2015 4:44 PM, "Pavel Serikov" <[email protected] 
> <javascript:>> wrote:
>
>> Hello dear colleagues,
>>
>> Can someone tell me why this script doesn't work?
>>
>> #!/usr/bin/env perl
>> use Mojo::UserAgent;
>> use feature 'say';
>> use utf8;
>>
>> my $ua = Mojo::UserAgent->new;
>> say $ua->get('
>> http://geocode-maps.yandex.ru/1.x/?geocode=Moscow&format=json')->res->
>> json->{response}->{GeoObjectCollection}->{featureMember}->[0]->{GeoObject
>> }->{metaDataProperty}->{GeocoderMetaData}->{AddressDetails}->{Country}->{
>> CountryName};
>>
>> When I run script I got such error:
>>
>> pavel@U310T:~/projects/test_scripts$ ./test_geocode.pl
>>> Can't use an undefined value as a HASH reference at ./test_geocode.pl 
>>> line 8.
>>>
>>
>> And seems like problem isn't in JSON structure or wrong Yandex API 
>> string. When I modified script to:
>>
>> #!/usr/bin/env perl
>> use Mojo::UserAgent;
>> use Data::Dumper;
>> use utf8;
>> my $ua = Mojo::UserAgent->new;
>> warn Dumper $ua->get('
>> https://geocode-maps.yandex.ru/1.x/?geocode=Moscow&format=json')->res->
>> json;
>>
>> I got:
>>
>> pavel@U310T:~/projects/test_scripts$ ./test_geocode.pl
>>> $VAR1 = undef;
>>>
>>
>> And as you can make sure API is working - 
>> https://geocode-maps.yandex.ru/1.x/?geocode=Moscow&format=json
>>
>> My Mojo version is latest
>>
>> sudo cpan -D Mojolicious
>>> Loading internal null logger. Install Log::Log4perl for logging messages
>>> Reading '/home/pavel/.cpan/Metadata'
>>>   Database was generated on Sat, 27 Jun 2015 04:41:02 GMT
>>> Mojolicious
>>> -------------------------------------------------------------------------
>>>     (no description)
>>>     D/DB/DBOOK/Mojolicious-6.12.tar.gz
>>>     /usr/local/share/perl/5.18.2/Mojolicious.pm
>>>     Installed: 6.12
>>>     CPAN:      6.12  up to date
>>>     Sebastian Riedel (SRI)
>>>     [email protected] <javascript:>
>>>
>>
>> I'm quite confused, cause recently this script worked... I didn't 
>> anything except updating Mojolicious to latest version.
>>
>> Any ideas?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Mojolicious" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/mojolicious.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to