in reply to Re: parse json data with underscore symbol
in thread parse json data with underscore symbol

Thanks a lot, it does print correctly now.
But when i want print ge value
print 'ge= ' . $decoded->{_embded}{stes}[1]{ge}, "\n"
I got this error.
Use of uninitialized value in concatenation (.) or string

Replies are listed 'Best First'.
Re^3: parse json data with underscore symbol
by kcott (Archbishop) on Aug 18, 2018 at 10:14 UTC

    Array indices are zero-based. The "ge" key is in the first element (i.e. index 0). So:

    $decoded->{_embded}{stes}[1]{ge} # BAD $decoded->{_embded}{stes}[0]{ge} # GOOD $decoded->{_embded}{ries}[1]{te} # BAD $decoded->{_embded}{ries}[0]{te} # GOOD

    By the way, "Use of uninitialized value ..." is a warning, not an error. See "perldiag - Perl diagnostic messages" for a description of this warning.

    — Ken

      Dear kcott, Thanks a lot for providing me these info. Just imagine that I have a very long of the data (Json) as i posted in the post. And I wand print all what I want by a loop to parse all the data. Can you suggest any module or way to do that?? Regards

      is a warning, not an error.

      It's still an error, just not an (immediately) fatal one.

      Thanks a lot, it is really useful.