Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^7: Help with JSON Module

by kcott (Abbot)
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:

$data->{Products}[0]{ProductId}

It seems to me that all you need is:

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

-- Ken


Comment on Re^7: Help with JSON Module
Select or Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2014-12-28 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (181 votes), past polls