Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Hmm, well, you can't treat a string as a hash or an array as a hash or a hash as an array

You can use eval to trap errors, ref to interrogate values to see what kind of reference they are, or Data::Diver which combines both, Re: Parsing SOAP::Lite results (with Data::Diver)

use strict; use warnings; use JSON qw/ encode_json decode_json /; my $json = <<'__JSON__'; { "fields" : { "customfield_11872" : [ { "name" : "", "self" : " +372", "released" : false, "id" : "35372", "archived" : false, "description" : "Null version. May be deleted after other +conforming versions are created" } ] } } __JSON__ my $decoded_json = decode_json( $json ); print $decoded_json->{'fields'}{'customfield_11872'}[0]{'name'}, "\n"; use Data::Diver qw/ Dive /; if( my $toyArrRef = Dive $decoded_json, qw/ fields customfield_11872 / + ){ for my $toy ( @{ $toyArrRef } ){ if( my $name = Dive $toy, qw/ name / ){ print "Name is $name\n"; } } } __END__ Name is

In reply to Re^4: Bad index while coercing array into hash by Anonymous Monk
in thread Bad index while coercing array into hash by Anonymous Monk

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (3)
    As of 2018-10-21 05:35 GMT
    Find Nodes?
      Voting Booth?
      When I need money for a bigger acquisition, I usually ...

      Results (119 votes). Check out past polls.