Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^7: Help with JSON Module

by kcott (Chancellor)
on Sep 08, 2012 at 11:38 UTC ( #992472=note: print w/replies, xml ) Need Help??

in reply to Re^6: Help with JSON Module
in thread Help with JSON Module

"Can you help with how to go on with the JSON decode statement?"

I'm rather at a loss as to why you want to use JSON and what you want to decode.

You've just demonstated that $tesco->product_search(...) returns Perl data (as a hashref) not JSON data.

In your OP, you showed that you knew how to navigate through the data structure to get to the value you wanted:


It seems to me that all you need is:

my $data = $tesco->product_search(...); my $prod_id = $data->{Products}[0]{ProductId};

-- Ken

Replies are listed 'Best First'.
Re^8: Help with JSON Module
by foggy3657 (Novice) on Sep 08, 2012 at 12:27 UTC

    Probably because I am so confused / an idiot. I got the impression reading the Tesco API that data was returned as JSON and I don't know the difference between Hashref and JSON.

    Extract from the API - A simpler HTTP-based interface using elements of the Representation State Transfer (REST) methodology. This interface uses commands and parameters embedded in HTTP URL requests, known as query-strings. The interface responds with data in a format called JavaScript Object Notation (JSON).

    However, I guess perhaps the Webservice::Tesco::API module is taking care of all that and converting it to a Perl Hashref. I was trying to learn to do things the right way rather than what I mistakenly thought might be the wrong way.

    Just remains to say thank you, to you and the others that have taken the time to help me and point me in the right direction. I have learnt something along the way.

    Best wishes - James. (I'm sure I'll be back with my next issue).

      Don't beat yourself up too much. We all started knowing nothing.

      You've learned from this experience. Learn more about Perl references by following the links Corion provided. Learn more about JSON here: Introducing JSON.

      -- Ken

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://992472]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2018-01-18 13:12 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (211 votes). Check out past polls.