Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: parse json data with underscore symbol

by kevbot (Priest)
on Aug 18, 2018 at 07:51 UTC ( #1220569=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2019-05-20 18:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (128 votes). Check out past polls.

    Notices?