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

Thank you for trying to help.

All your code returns is HASH(0x9fbf738)

I have tried the validator and it definitely returns Valid.

I can't help thinking that my JSON decode syntax is incorrect somehow.

Best wishes - James

Replies are listed 'Best First'.
Re^3: Help with JSON Module
by kcott (Archbishop) on Sep 08, 2012 at 08:33 UTC

    And there's your problem identified.

    JSON's decode method has this syntax:

    $perl_scalar = $json->decode($json_text)

    but you're invoking it as:

    $perl_scalar = $json->decode($hash_reference)

    Use Data::Dumper to determine what data the hash reference points to. Perhaps your JSON string is in there somewhere.

    -- Ken

      Thank you. However with the following code:

      #!/usr/bin/perl use warnings; use strict; use WebService::Tesco::API; use JSON; use Data::Dumper my $tesco = WebService::Tesco::API->new( app_key => 'xxxxx', developer +_key => 'xxxx', debug => 1, ); my $result = $tesco->login({ email => 'xxxxx@yahoo.co.uk', password => + 'xxxxx', }); print "Scan Item...."; my $pn = <>; #Scan Bar Code chop ($pn); # +remove %OA from end of scan code my $code = $tesco->product_search({ searchtext => $pn, extendedinfo => + 'N' }); print Dumper ($code);

      All I get is:

      "WebService::Tesco::API=HASH(0xf66940)" is not exported by the Data::D +umper module Can't continue after import errors at tesco_json_dumper.pl line 9. BEGIN failed--compilation aborted at tesco_json_dumper.pl line 9.

        You are missing a semicolon after use Data::Dumper.

        The correct line should be

        use Data::Dumper; # ^ Note the added semicolon here