i have post and got the response very well from the server {"name":"Jerry Stephin","country":"uk","email":"brabrabra"} -------------------- Content-type: text/html Response code: 200 Content-type: text/html bt my problem is that how can i format the json response and print out the message well-formatted like this

name brbrr

email brbbr

country brbr

i tried this bt cant work

#!"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"; }

In reply to json response by bigup401

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.