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

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

  • Comment on Re^5: parse json data with underscore symbol

Replies are listed 'Best First'.
Re^6: parse json data with underscore symbol
by kevbot (Vicar) on Aug 20, 2018 at 04:41 UTC
    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.