http://qs321.pair.com?node_id=1220563


in reply to parse json data with underscore symbol

Hello amaa11, Please see Writeup Formatting Tips for advice on how to properly format your post. When I copy & paste your code from the perlmonks page and run it, I get a error related to improperly formatted JSON. I think your JSON string is not being displayed properly on the site, and this should be fixed by wrapping your code with <code> tags.

Replies are listed 'Best First'.
Re^2: parse json data with underscore symbol
by kevbot (Vicar) on Aug 18, 2018 at 07:25 UTC
    Hello amaa11,

    I see that you added the code tags, but now your code is no longer valid perl syntax due to the appearance of extra <br> tags on every line.

    UPDATE: I see that you fixed the formatting problems, but now when I run your code I get an error related to improperly formatted JSON. When I run your code as is, I get this error '"' expected, at character offset 811 (before "<br>\n        "count...") at t.pl line 108. When I manually remove the offending <br> tag, I finally get the error that you mentioned Not a HASH reference at t.pl line 110.
      Dear kevbot,
      Yes I updated the all post as you asked
      still have a small problem when I print the second element in the array
      print 'ge= ' . $decoded->{_embded}{stes}[1]{ge}, "\n"
      I got this error.
      Use of uninitialized value in concatenation (.) or string
        The array reference given by $decoded->{_embded}{stes} only has one element so the data is at index 0. Try this, $decoded->{_embded}{stes}[0]{ge}