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


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

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}

Replies are listed 'Best First'.
Re^5: parse json data with underscore symbol
by amaa11 (Initiate) on Aug 19, 2018 at 10:05 UTC

    Dear Kevbot, 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

      Hello amaa11,

      It's difficult to give advice because the code you need to write will be highly dependent on the data structure returned by decode_json, which is highly dependent on the structure of your JSON string.

      If you are going to be extracting data from complex JSON strings, then it may be helpful to use a module that helps you extract the data (without having to worry about the perl data structure). One such module is JSON::Path. It lets your write a JSONPath string to extract the data. This way you can write a JSONPath string that will extract only the portion of data that you are interested in and it will reduce the amount of perl code you need to write. I have converted your script of use JSON::Path to give you an example to work from.

      If you choose to use this module, I recommend you carefully read the documentation for the JSON::Path and JSONPath - XPath for JSON.