I fed your blob of code into perltidy, which complained about certain errors. I made minimal changes to satisfy perltidy, and wound up with the following:

%responce_array1 = (); %responce_array2 = (); $responce_array1{'REQUEST'}{'Items'}{0}{'ItemName'} = 'demoName0'; $responce_array1{'REQUEST'}{'Items'}{1}{'ItemName'} = 'demoName1'; $responce_array1{'REQUEST'}{'Items'}{2}{'ItemName'} = 'demoName2'; my $itemjson_ary1 = encode_json \%responce_array1; $responce_array2{'item_json_array'} = $itemjson_ary1; my $itemjson_ary2 = encode_json \%responce_array2; print $itemjson_ary2; $jsonary = '{"item_json_array":"{\"REQUEST\":{\"Items\":{\"1\":{\"ItemName\": +\"demoName1\"},\"0\":{\"ItemName\":\"demoName0\"},\"2\":{\"ItemName\" +:\"demoName2\"}}}}"}'; $dec_json_obj = decode_json $jsonary; $temp = $dec_json_obj->{item_json_array}; $dec_json_obj = decode_json $temp; $temp = $dec_json_obj->{REQUEST}; #hash form $dec_json_obj=&get_hash_to_str($temp); $temp = $dec_json_obj->{Items}; $dec_json_obj = &get_hash_to_str($temp); $temp = $dec_json_obj->{0}; $dec_json_obj = &get_hash_to_str($temp); print $temp= $dec_json_obj->{ItemName}; sub get_hash_to_str($temp) { my $temp = $_[0]; my $enc_json_req = encode_json $temp; print " "; print $enc_json_req; print " "; my $dec_json_obj = decode_json $enc_json_req; return $dec_json_obj; } # Here i am sending values like these to retrieve # 0-th element of item and get ItemName # $temp = $dec_json_obj->{0}; $dec_json_obj = &get_hash_to_str($temp); print $temp= $dec_json_obj->{ItemName};

I've made some minor spelling corrections.

my ( %response1, %response2 ); $response1{REQUEST}{Items}[0]{ItemName} = 'demoName0'; $response1{REQUEST}{Items}[1]{ItemName} = 'demoName1'; $response1{REQUEST}{Items}[2]{ItemName} = 'demoName2'; my $itemjson_ary1 = encode_json \%response1; $response2{item_json_array} = $itemjson_ary1; my $itemjson_ary2 = encode_json \%resposce2; print $itemjson_ary2; $jsonary = '{"item_json_array":"{\"REQUEST\":{\"Items\":{\"1\":{\"ItemName\": +\"demoName1\"},\"0\":{\"ItemName\":\"demoName0\"},\"2\":{\"ItemName\" +:\"demoName2\"}}}}"}'; $dec_json_obj = decode_json $jsonary; $temp = $dec_json_obj->{item_json_array}; $dec_json_obj = decode_json $temp; $temp = $dec_json_obj->{REQUEST}; # hash form $dec_json_obj = get_hash_to_str($temp); $temp = $dec_json_obj->{Items}; $dec_json_obj = get_hash_to_str($temp); $temp = $dec_json_obj->{0}; $dec_json_obj = get_hash_to_str($temp); print $temp = $dec_json_obj->{ItemName}; sub get_hash_to_str($temp) { my ( $stringify_me ) = @_; my $enc_json_req = encode_json $stringify_me; print " "; print $enc_json_req; print " "; my $dec_json_obj = decode_json $enc_json_req; return $dec_json_obj; } # Here i am sending values like these to retrieve # 0-th element of item and get ItemName # $temp = $dec_json_obj->[0]; $dec_json_obj = get_hash_to_str($temp); print $temp = $dec_json_obj->{ItemName};

Hope this helps a little.

As Occam said: Entia non sunt multiplicanda praeter necessitatem.


In reply to Re: How can we retrieve encode_json value which is in encode_json associative array formate. by TomDLux
in thread How can we retrieve encode_json value which is in encode_json associative array formate. by deepakgate6

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.