Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^7: Help with JSON Module

by remiah (Hermit)
on Sep 08, 2012 at 09:41 UTC ( #992460=note: print w/replies, xml ) Need Help??

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

I guess tobyink's reply will help you.
How is your $code?
This works with my environment without warning, error.
#!/usr/bin/perl use strict; use warnings; use JSON; use Data::Dumper; my $json = JSON->new; my $code=join('', (<DATA>)); print Dumper $code; my $data = $json->decode($code); __DATA__ { "StatusCode": 0, "StatusInfo": "Command Processed OK", "PageNumber": 0, "TotalPageCount": 1, "TotalProductCount": 1, "PageProductCount": 1, "Products": [ { "BaseProductId": "50043662", "EANBarcode": "5000175411118", "CheaperAlternativeProductId": "", "HealthierAlternativeProductId": "", "ImagePath": " +ot_90x90.jpg", "MaximumPurchaseQuantity": 99, "Name": "Oxo 12 Chicken Stock Cubes 71G", "OfferPromotion": "Price Drop Was 1.13 Now 1.00 ", "OfferValidity": "valid from 30/7/2012 until 9/9/2012", "OfferLabelImagePath": " +s/Retail/Superstore/ "Price": 1, "PriceDescription": "1.41 each", "ProductId": "254881114", "ProductType": "QuantityOnlyProduct", "UnitPrice": 1.41, "UnitType": "100g" } ] }

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

    Thank you. After making a stupid syntax error. $code returns the following using Dumper.

    $VAR1 = { 'StatusCode' => 0, 'Products' => [ { 'UnitType' => '100g', 'HealthierAlternativeProductId' => '', 'OfferPromotion' => "Price Drop Was \x{a3} +1.13 Now \x{a3}1.00 ", 'ProductId' => '254881114', 'EANBarcode' => '5000175411118', 'MaximumPurchaseQuantity' => 99, 'CheaperAlternativeProductId' => '', 'ProductType' => 'QuantityOnlyProduct', 'PriceDescription' => "\x{a3}1.41 each", 'UnitPrice' => '1.41', 'ImagePath' => ' +ries/pi/118/5000175411118/IDShot_90x90.jpg', 'Price' => 1, 'BaseProductId' => '50043662', 'Name' => 'Oxo 12 Chicken Stock Cubes 71G' +, 'OfferValidity' => 'valid from 30/7/2012 u +ntil 9/9/2012', 'OfferLabelImagePath' => 'http://www.tesco +save.png' } ], 'TotalProductCount' => 1, 'PageNumber' => 0, 'TotalPageCount' => 1, 'StatusInfo' => 'Command Processed OK', 'PageProductCount' => 1

    I am now looking at a few links to understand references. But to be honest I am not sure I understand what got returned. A Hash or an Array.

        Thank you for your patience, but I'm just not understanding what I'm reading.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://992460]
[marto]: obviously someone could be religious, but not creationist
[erix]: "Nothing in Intelligent Design makes sense except in the light of Creationism" <-- I made that one up myself (free after Dobzhansky )
[erix]: yes. Deplorable marto, deplorable.
[marto]: the situation seemed similar to this one, majority of the contributrions are nonsense, doesn't address any questions ...
[marto]: meh, I've been called worse :P
[marto]: deplorable is actually not bad for this point in the day :P
[erix]: we aim to satisfy
[erix]: churches are good excuses for large-scale architecture -- which is nice

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2017-07-28 15:50 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (431 votes). Check out past polls.