{"name":"Jerry Stephin","country":"uk","email":"brabrabra"} -------------------- Content-type: text/html Response code: 200 Content-type: text/html #### #!"C:\xampp\perl\bin\perl.exe" use LWP::UserAgent; use HTTP::Request::Common qw(POST); use JSON::XS; my $ua = new LWP::UserAgent(keep_alive=>1); my $responde = HTTP::Request->new(POST =>""); $responde->content_type("application/x-www-form-urlencoded"); $responde->content_type("Content-Type' => 'application/json"); my $responseObj = $ua->request($responde); print "Content-type: text/html\n\n"; print $responseObj->content."\n--------------------\n"; my $responseCode = $responseObj->code; print "Content-type: text/html\n\n"; print 'Response code: ' . $responseCode . "\n"; $isSuccesResponse = $responseCode < 400; my $response = JSON::XS->new->decode ($responseObj->content); if ($isSuccesResponse) { package json_res; sub new { my $class = shift; my $self = { name => shift, email => shift, country => shift, }; bless $self, $class; return $self; } sub TO_JSON { return { %{ shift() } }; } package main; use JSON; my $JSON = JSON->new->utf8; $JSON->convert_blessed(1); my $js = new json_res($response); my $json = $JSON->encode($js); sub getname { my( $self ) = @_; return $self->{name}; } sub getemail { my( $self ) = @_; return $self->{email}; } sub getcountry { my( $self ) = @_; return $self->{country}; } my $name = $json->getname(); my $email = $json->getemail(); my $country = $json->getcountry(); print "Names Is: $name\n"; print "Email Is: $email\n"; print "Country Is: $country\n"; }