Does this help?

Not as much as it could; because its data is not bundled with the code it is not a short, self-contained example. To provide a complete answer someone would have to do the extra work of reverse-engineering your data-structure to figure out what it looked like in the first place. And frankly, many potential answers will not be written, or will be less helpful than they could have been because the prospect of extra, error-prone work of reverse-engineering sample data from code that is known to be buggy discourages people from helping, particularly when it would not be much effort for the person asking to provide a small data sample in the first place.

Your code snippet could have been like this:

use strict; use warnings; use JSON qw(decode_json); my $json_decoded = decode_json(do {local $/ = undef; <DATA>}); #...your code goes here... __DATA__ {"foo":"bar", "baz":["buzz":1] }

...or...

use strict; use warnings; my $json_decoded = {foo => 'bar', baz => ['buzz', 1]}; # Your code goes here...

In either case we would have all the facts in front of us, and could run your sample code and see the output you are seeing.

At any rate, see my answer at a higher-level in this thread for an explanation of the benefit of diagnostics when a terse error message feels cryptic.


Dave


In reply to Re^3: keys in reference experimental or reference is deprecated by davido
in thread keys in reference experimental or reference is deprecated by demichi

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.