Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: parse json data with underscore symbol

by choroba (Cardinal)
on Aug 18, 2018 at 07:15 UTC ( [id://1220562]=note: print w/replies, xml ) Need Help??


in reply to parse json data with underscore symbol

Please, fix your question using the <code>...</code> tags.

"stes" seems to be an array, so you need to index it with square brackets:

print 'SampleSize = ' . $decoded->{_embded}{stes}[0]{SampleSize}, "\n" +;

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: parse json data with underscore symbol
by kevbot (Vicar) on Aug 18, 2018 at 07:35 UTC
    When the code and JSON are formatted properly (OP updated their post a few times), your suggestion fixes the problem.
Re^2: parse json data with underscore symbol
by amaa11 (Initiate) on Aug 18, 2018 at 07:40 UTC
    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

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1220562]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 21:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found